forked from shaarli/Shaarli
-
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.
Use php-intl extension to display datetimes a bit more nicely, depending on the locale. What changes: * the day is no longer displayed * day number and month are ordered according to the locale * the timezone is more readable (UTC+1 instead of CET)
- Loading branch information
1 parent
1255a42
commit 52b5031
Showing
8 changed files
with
174 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
if (! empty('UT_LOCALE')) { | ||
setlocale(LC_ALL, getenv('UT_LOCALE')); | ||
} | ||
|
||
require_once 'vendor/autoload.php'; | ||
|
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,25 @@ | ||
<?php | ||
|
||
require_once 'tests/UtilsTest.php'; | ||
|
||
|
||
class UtilsDeTest extends UtilsTest | ||
{ | ||
/** | ||
* Test date_format(). | ||
*/ | ||
public function testDateFormat() | ||
{ | ||
$date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
$this->assertRegExp('/1. Januar 2017 (um )?10:11:12 GMT\+0?3(:00)?/', format_date($date, true)); | ||
} | ||
|
||
/** | ||
* Test date_format() using builtin PHP function strftime. | ||
*/ | ||
public function testDateFormatDefault() | ||
{ | ||
$date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
$this->assertEquals('So 01 Jan 2017 10:11:12 EAT', format_date($date, false)); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
require_once 'tests/UtilsTest.php'; | ||
|
||
|
||
class UtilsEnTest extends UtilsTest | ||
{ | ||
/** | ||
* Test date_format(). | ||
*/ | ||
public function testDateFormat() | ||
{ | ||
$date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
$this->assertRegExp('/January 1, 2017 (at )?10:11:12 AM GMT\+0?3(:00)?/', format_date($date, true)); | ||
} | ||
|
||
/** | ||
* Test date_format() using builtin PHP function strftime. | ||
*/ | ||
public function testDateFormatDefault() | ||
{ | ||
$date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
$this->assertEquals('Sun 01 Jan 2017 10:11:12 AM EAT', format_date($date, false)); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
require_once 'tests/UtilsTest.php'; | ||
|
||
|
||
class UtilsFrTest extends UtilsTest | ||
{ | ||
/** | ||
* Test date_format(). | ||
*/ | ||
public function testDateFormat() | ||
{ | ||
$date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
$this->assertRegExp('/1 janvier 2017 (à )?10:11:12 UTC\+0?3(:00)?/', format_date($date)); | ||
} | ||
|
||
/** | ||
* Test date_format() using builtin PHP function strftime. | ||
*/ | ||
public function testDateFormatDefault() | ||
{ | ||
$date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
$this->assertEquals('dim. 01 janv. 2017 10:11:12 EAT', format_date($date, false)); | ||
} | ||
} |
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