-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added filters |localDate & |localTime [WIP]
- Loading branch information
Showing
4 changed files
with
74 additions
and
0 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,41 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Latte\Essential\Filters::localDate() | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Latte\Essential\Filters; | ||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
ini_set('intl.default_locale', 'cs_CZ'); | ||
|
||
// types of value | ||
Assert::null(Filters::localDate(null)); | ||
Assert::same("23.\u{a0}1.\u{a0}1978", Filters::localDate(254_400_000)); | ||
Assert::same("5.\u{a0}5.\u{a0}1978", Filters::localDate('1978-05-05')); | ||
Assert::same("5.\u{a0}5.\u{a0}1978", Filters::localDate(new DateTime('1978-05-05'))); | ||
|
||
// predefined date format | ||
Assert::same('05.05.78', Filters::localDate(new DateTime('1978-05-05'), 'short')); | ||
Assert::same("5.\u{a0}5.\u{a0}1978", Filters::localDate(new DateTime('1978-05-05'), 'medium')); | ||
Assert::same("5.\u{a0}května 1978", Filters::localDate(new DateTime('1978-05-05'), 'long')); | ||
Assert::same("pátek 5.\u{a0}května 1978", Filters::localDate(new DateTime('1978-05-05'), 'full')); | ||
|
||
// predefined time format | ||
Assert::same('12:13', Filters::localDate(new DateTime('12:13:14'), 'time')); | ||
Assert::same('12:13:14', Filters::localDate(new DateTime('12:13:14'), 'time+sec')); | ||
|
||
// combined | ||
Assert::same('05.05.78 12:13', Filters::localDate(new DateTime('1978-05-05'), 'short+time')); | ||
|
||
// custom format | ||
Assert::same("po, led 23, '78", Filters::localDate(254_400_000, "EEE, MMM d, ''yy")); | ||
|
||
// timestamp & timezone | ||
date_default_timezone_set('America/Los_Angeles'); | ||
Assert::same('7:09:31', Filters::localDate(1_408_284_571, 'time+sec')); |