Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DateTime: createFromFormat() returns Nette\Utils\DateTime instance
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
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,27 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Nette\DateTime::createFromFormat(). | ||
* | ||
* @author Radek Je啪d铆k | ||
*/ | ||
|
||
use Tester\Assert, | ||
Nette\Utils\DateTime; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
date_default_timezone_set('Europe/Prague'); | ||
|
||
Assert::type( 'Nette\Utils\DateTime', DateTime::createFromFormat('Y-m-d H:i:s', '2050-08-13 11:40:00') ); | ||
Assert::type( 'Nette\Utils\DateTime', DateTime::createFromFormat('Y-m-d H:i:s', '2050-08-13 11:40:00', new DateTimeZone('Europe/Prague')) ); | ||
|
||
Assert::same( '2050-08-13 11:40:00', (string) DateTime::createFromFormat('Y-m-d H:i:s', '2050-08-13 11:40:00') ); | ||
|
||
Assert::same( 'Europe/Prague', DateTime::createFromFormat('Y', '2050')->getTimezone()->getName() ); | ||
Assert::same( 'Europe/Bratislava', DateTime::createFromFormat('Y', '2050', 'Europe/Bratislava')->getTimezone()->getName() ); | ||
|
||
Assert::error(function(){ | ||
DateTime::createFromFormat('Y-m-d H:i:s', '2050-08-13 11:40:00', 5); | ||
}, 'Nette\InvalidArgumentException', 'Invalid timezone given' ); |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Nette\Utils\DateTime test. | ||
* Test: Nette\Utils\DateTime::from(). | ||
* | ||
* @author David Grudl | ||
*/ | ||
|