-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add timezones support, fix create from format methods
- Loading branch information
1 parent
1617c45
commit c3dfe1e
Showing
4 changed files
with
61 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mistrfilda\Datetime\Timezone; | ||
|
||
use DateTimeZone; | ||
|
||
class Timezone | ||
{ | ||
public const UTC = 'UTC'; | ||
|
||
public const PRAGUE = 'Europe/Prague'; | ||
|
||
public static function createTimezone(string $zone): DateTimeZone | ||
{ | ||
return new DateTimeZone($zone); | ||
} | ||
|
||
public static function getUTCTimezone(): DateTimeZone | ||
{ | ||
return new DateTimeZone(self::UTC); | ||
} | ||
|
||
public static function getPragueTimezone(): DateTimeZone | ||
{ | ||
return new DateTimeZone(self::PRAGUE); | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mistrfilda\Datetime\Tests\Unit\Timezone; | ||
|
||
use Mistrfilda\Datetime\Tests\Unit\BaseUnitTest; | ||
use Mistrfilda\Datetime\Timezone\Timezone; | ||
|
||
class TimezoneTest extends BaseUnitTest | ||
{ | ||
public function testTimezones(): void | ||
{ | ||
self::assertSame( | ||
'Europe/Prague', | ||
Timezone::getPragueTimezone()->getName() | ||
); | ||
|
||
self::assertSame( | ||
'UTC', | ||
Timezone::getUTCTimezone()->getName() | ||
); | ||
} | ||
} |
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