fix timezone problem
This commit is contained in:
parent
cc02f7aa60
commit
09c3ea1e5e
|
@ -70,6 +70,9 @@ class CarbonHandler implements SubscribingHandlerInterface
|
|||
*/
|
||||
public function serializeCarbon(VisitorInterface $visitor, Carbon $date, array $type, Context $context)
|
||||
{
|
||||
$date = clone $date;
|
||||
$date->setTimezone($this->defaultTimezone);
|
||||
|
||||
return $visitor->visitString($date->format($this->getFormat($type)), $type, $context);
|
||||
}
|
||||
|
||||
|
@ -94,6 +97,8 @@ class CarbonHandler implements SubscribingHandlerInterface
|
|||
throw new RuntimeException(sprintf('Invalid datetime "%s", expected format %s.', $data, $format));
|
||||
}
|
||||
|
||||
$datetime->setTimezone(new \DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
return $datetime;
|
||||
}
|
||||
|
||||
|
|
11
src/Task.php
11
src/Task.php
|
@ -125,7 +125,7 @@ class Task
|
|||
public function __construct()
|
||||
{
|
||||
$this->urgency = 0;
|
||||
$this->entry = new Carbon('now', new \DateTimeZone('UTC'));
|
||||
$this->entry = new Carbon('now');
|
||||
$this->status = self::STATUS_PENDING;
|
||||
}
|
||||
|
||||
|
@ -387,18 +387,15 @@ class Task
|
|||
private function parseDateTime($date)
|
||||
{
|
||||
if ($date instanceof \DateTime) {
|
||||
return new Carbon($date->format('Y-m-d H:i:s'), new \DateTimeZone('UTC'));
|
||||
return new Carbon($date->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
if ($date instanceof Carbon) {
|
||||
$date = clone $date;
|
||||
$date->setTimezone(new \DateTimeZone('UTC'));
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
if (is_string($date)) {
|
||||
return new Carbon($date, new \DateTimeZone('UTC'));
|
||||
return new Carbon($date);
|
||||
}
|
||||
|
||||
if ($date === null) {
|
||||
|
@ -414,7 +411,7 @@ class Task
|
|||
public function __clone()
|
||||
{
|
||||
$this->uuid = null;
|
||||
$this->entry = new Carbon('now', new \DateTimeZone('UTC'));
|
||||
$this->entry = new Carbon('now');
|
||||
$this->status = self::STATUS_PENDING;
|
||||
}
|
||||
}
|
|
@ -707,6 +707,6 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
private function createDateTime($string = 'now')
|
||||
{
|
||||
return new \DateTime($string, new \DateTimeZone('UTC'));
|
||||
return new \DateTime($string);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue