Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Instant.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public function jsonSerialize(): string
*/
public function toISOString(): string
{
return (string) ZonedDateTime::ofInstant($this, TimeZone::utc());
return (string) ZonedDateTime::ofInstant($this, TimeZoneOffset::utc());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/LocalDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ public function isPast(TimeZone $timeZone, ?Clock $clock = null): bool
*/
public function toNativeDateTime(): DateTime
{
return $this->atTimeZone(TimeZone::utc())->toNativeDateTime();
return $this->atTimeZone(TimeZoneOffset::utc())->toNativeDateTime();
}

/**
Expand Down
4 changes: 0 additions & 4 deletions src/TimeZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public static function parse(string $text): TimeZone
return TimeZoneRegion::parse($text);
}

public static function utc(): TimeZoneOffset
{
return TimeZoneOffset::utc();
}

/**
* Returns the unique time-zone ID.
Expand Down
5 changes: 5 additions & 0 deletions src/TimeZoneRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public static function from(DateTimeParseResult $result): TimeZoneRegion
return TimeZoneRegion::of($region);
}

public static function utc() : TimeZoneRegion
{
return TimeZoneRegion::of('UTC');
}

/**
* Returns all the available time-zone identifiers.
*
Expand Down
4 changes: 2 additions & 2 deletions tests/InstantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Brick\DateTime\DateTimeException;
use Brick\DateTime\Duration;
use Brick\DateTime\Instant;
use Brick\DateTime\TimeZone;
use Brick\DateTime\TimeZoneOffset;
use PHPUnit\Framework\Attributes\DataProvider;

use function json_encode;
Expand Down Expand Up @@ -658,7 +658,7 @@ public static function providerToString(): array

public function testAtTimeZone(): void
{
$timeZone = TimeZone::utc();
$timeZone = TimeZoneOffset::utc();
$instant = Instant::of(1000000000);
$result = $instant->atTimeZone($timeZone);
self::assertSame(1000000000, $result->getInstant()->getEpochSecond());
Expand Down
1 change: 1 addition & 0 deletions tests/TimeZoneOffsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Brick\DateTime\TimeZoneOffset;
use DateTimeImmutable;
use PHPUnit\Framework\Attributes\DataProvider;
use Brick\DateTime\TimeZoneRegion;

use const PHP_VERSION_ID;

Expand Down
7 changes: 7 additions & 0 deletions tests/TimeZoneRegionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,11 @@ public function testToString(): void
{
self::assertSame('America/Los_Angeles', (string) TimeZoneRegion::of('America/Los_Angeles'));
}

public function testUTC(): void
{
$utcTimeZoneRegion = TimeZoneRegion::utc();
$this->assertInstanceOf(TimeZoneRegion::class, $utcTimeZoneRegion);
$this->assertSame('UTC', $utcTimeZoneRegion->getId());
}
}
9 changes: 3 additions & 6 deletions tests/TimeZoneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,13 @@ public static function providerParseInvalidStringThrowsException(): array

public function testUtc(): void
{
$utc = TimeZone::utc();

self::assertTimeZoneOffsetIs(0, $utc);
self::assertSame($utc, TimeZone::utc());
$this->assertTimeZoneOffsetIs(0, TimeZoneOffset::utc());
}

public function testIsEqualTo(): void
{
self::assertTrue(TimeZone::utc()->isEqualTo(TimeZoneOffset::ofTotalSeconds(0)));
self::assertFalse(TimeZone::utc()->isEqualTo(TimeZoneOffset::ofTotalSeconds(3600)));
self::assertTrue(TimeZoneOffset::utc()->isEqualTo(TimeZoneOffset::ofTotalSeconds(0)));
self::assertFalse(TimeZoneOffset::utc()->isEqualTo(TimeZoneOffset::ofTotalSeconds(3600)));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/ZonedDateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public function testGetMonth(int $monthValue, Month $month): void
{
$zonedDateTime = ZonedDateTime::of(
LocalDateTime::of(2000, $monthValue, 1),
TimeZone::utc(),
TimeZoneOffset::utc(),
);

self::assertSame($month, $zonedDateTime->getMonth());
Expand Down