Skip to content

Commit

Permalink
Merge pull request #424 from cakephp/add-todatetimeimmutable
Browse files Browse the repository at this point in the history
Rename toNative() toDateTimeImmutable()
  • Loading branch information
othercorey authored Sep 24, 2023
2 parents aa49da4 + e04f530 commit af68da5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/ChronosDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -1564,11 +1564,11 @@ public function diffForHumans(?ChronosDate $other = null, bool $absolute = false
}

/**
* Returns the date as a DateTimeImmutable instance.
* Returns the date as a `DateTimeImmutable` instance.
*
* @return \DateTimeImmutable
*/
public function toNative(): DateTimeImmutable
public function toDateTimeImmutable(): DateTimeImmutable
{
return $this->native;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ChronosTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ protected static function mod(int $a, int $b): int
*/
public function format(string $format): string
{
return $this->toNative()->format($format);
return $this->toDateTimeImmutable()->format($format);
}

/**
Expand Down Expand Up @@ -404,7 +404,7 @@ public function between(ChronosTime $start, ChronosTime $end, bool $equals = tru
*
* @return \DateTimeImmutable
*/
public function toNative(): DateTimeImmutable
public function toDateTimeImmutable(): DateTimeImmutable
{
return (new DateTimeImmutable())->setTime(
$this->getHours(),
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/ChronosTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public function testComparisons(): void
$this->assertFalse($t3->between($t1, $t2));
}

public function testToNative(): void
public function testToDateTimeImmutable(): void
{
$native = ChronosTime::parse('23:59:59.999999')->toNative();
$native = ChronosTime::parse('23:59:59.999999')->toDateTimeImmutable();
$this->assertSame('23:59:59.999999', $native->format('H:i:s.u'));
}
}
4 changes: 2 additions & 2 deletions tests/TestCase/Date/StringsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ public function testToW3cString()
$this->assertSame('1975-12-25T00:00:00+00:00', $d->toW3cString());
}

public function testToNative(): void
public function testToDateTimeImmutable(): void
{
$d = ChronosDate::now();
$this->assertSame($d->format('Y-m-d'), $d->toNative()->format('Y-m-d'));
$this->assertSame($d->format('Y-m-d'), $d->toDateTimeImmutable()->format('Y-m-d'));
}
}

0 comments on commit af68da5

Please sign in to comment.