Skip to content

Commit

Permalink
switch to microseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
kunicmarko20 committed Jan 8, 2020
1 parent b977c8a commit 3e65b69
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions generator/tests/DateTimeImmutableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ public function testEquals(): void
{
$phpDateTime = new \DateTimeImmutable();

$safeDateTime1 = \Safe\DateTimeImmutable::createFromFormat('Y-m-d H:i:s.v', $phpDateTime->format('Y-m-d H:i:s.v'));
$safeDateTime2 = new \Safe\DateTimeImmutable($safeDateTime1->format('Y-m-d H:i:s.v'));
$safeDateTime1 = \Safe\DateTimeImmutable::createFromFormat('Y-m-d H:i:s.u', $phpDateTime->format('Y-m-d H:i:s.u'));
$safeDateTime2 = new \Safe\DateTimeImmutable($safeDateTime1->format('Y-m-d H:i:s.u'));

$this->assertEquals($phpDateTime, $safeDateTime1);
$this->assertEquals($phpDateTime, $safeDateTime2);
Expand Down
2 changes: 1 addition & 1 deletion lib/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DateTime extends \DateTime
//switch from regular datetime to safe version
private static function createFromRegular(\DateTime $datetime): self
{
return new self($datetime->format('Y-m-d H:i:s.v'), $datetime->getTimezone());
return new self($datetime->format('Y-m-d H:i:s.u'), $datetime->getTimezone());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/DateTimeImmutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct($time = 'now', $timezone = null)
//switch from regular datetime to safe version
private static function createFromRegular(\DateTimeImmutable $datetime): self
{
$safeDatetime = new self($datetime->format('Y-m-d H:i:s.v'), $datetime->getTimezone()); //we need to also update the wrapper to not break the operators '<' and '>'
$safeDatetime = new self($datetime->format('Y-m-d H:i:s.u'), $datetime->getTimezone()); //we need to also update the wrapper to not break the operators '<' and '>'
$safeDatetime->innerDateTime = $datetime;
return $safeDatetime;
}
Expand Down

0 comments on commit 3e65b69

Please sign in to comment.