Commit 2b063e97 authored by Jeroen Herczeg's avatar Jeroen Herczeg Committed by Markus Kalkbrenner

Fix for issue #253 clone datetime (#613)

* Clone datetime before changing timezone

* Test for clone datetime before changing timezone
parent 8549692b
......@@ -110,7 +110,7 @@ class Helper
switch (true) {
// input of datetime object
case $input instanceof \DateTimeInterface:
// no work needed
$input = clone $input;
break;
// input of timestamp or date/time string
case is_string($input) || is_numeric($input):
......
......@@ -264,6 +264,21 @@ class RequestBuilderTest extends TestCase
);
}
public function testBuildAddXmlWithDateTimeImmutable()
{
$timezone = new \DateTimeZone('Europe/London');
$date = new \DateTime('2013-01-15 14:41:58', $timezone);
$command = new AddCommand();
$command->addDocument(
new Document(['id' => 1, 'datetime' => $date])
);
$this->builder->buildAddXml($command, $this->query);
$this->assertEquals($timezone->getName(), $date->getTimezone()->getName());
}
public function testBuildAddXmlWithFieldModifierAndNullValue()
{
$doc = new Document();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment