-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fixes timezone formatting when inspecting KSUID.
- Loading branch information
1 parent
10d6a5c
commit 848e244
Showing
5 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace TinyBlocks\Ksuid\Internal; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class TimestampTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider providerForTestFormatWithDifferentTimezones | ||
*/ | ||
public function testFormatWithDifferentTimezones(string $timezone, string $expected): void | ||
{ | ||
$default = date_default_timezone_get(); | ||
date_default_timezone_set($timezone); | ||
|
||
$timestamp = Timestamp::from(value: 107608047); | ||
|
||
$actual = $timestamp->toUnixTimeFormatted(); | ||
|
||
self::assertEquals($expected, $actual); | ||
|
||
date_default_timezone_set($default); | ||
} | ||
|
||
public function providerForTestFormatWithDifferentTimezones(): array | ||
{ | ||
return [ | ||
[ | ||
'timezone' => 'America/Sao_Paulo', | ||
'expected' => '2017-10-10 01:00:47 -0300 -03' | ||
], | ||
[ | ||
'timezone' => 'America/New_York', | ||
'expected' => '2017-10-10 00:00:47 -0400 EDT' | ||
], | ||
[ | ||
'timezone' => 'Europe/London', | ||
'expected' => '2017-10-10 05:00:47 +0100 BST' | ||
] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters