diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-01-07 14:30:42 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2017-03-06 21:11:12 +0100 |
commit | 52b503105d389d1796698114573ff618b2ad34a2 (patch) | |
tree | d636098fe0864db98c175cd7dfda19a1c069eb82 /tests/languages | |
parent | 1255a42cfed9ce419962c6cf29181a66c7e22bb8 (diff) | |
download | Shaarli-52b503105d389d1796698114573ff618b2ad34a2.tar.gz Shaarli-52b503105d389d1796698114573ff618b2ad34a2.tar.zst Shaarli-52b503105d389d1796698114573ff618b2ad34a2.zip |
Improve datetime display
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)
Diffstat (limited to 'tests/languages')
-rw-r--r-- | tests/languages/bootstrap.php | 7 | ||||
-rw-r--r-- | tests/languages/de/UtilsDeTest.php | 25 | ||||
-rw-r--r-- | tests/languages/en/UtilsEnTest.php | 25 | ||||
-rw-r--r-- | tests/languages/fr/UtilsFrTest.php | 25 |
4 files changed, 82 insertions, 0 deletions
diff --git a/tests/languages/bootstrap.php b/tests/languages/bootstrap.php new file mode 100644 index 00000000..95609210 --- /dev/null +++ b/tests/languages/bootstrap.php | |||
@@ -0,0 +1,7 @@ | |||
1 | <?php | ||
2 | if (! empty('UT_LOCALE')) { | ||
3 | setlocale(LC_ALL, getenv('UT_LOCALE')); | ||
4 | } | ||
5 | |||
6 | require_once 'vendor/autoload.php'; | ||
7 | |||
diff --git a/tests/languages/de/UtilsDeTest.php b/tests/languages/de/UtilsDeTest.php new file mode 100644 index 00000000..8a740389 --- /dev/null +++ b/tests/languages/de/UtilsDeTest.php | |||
@@ -0,0 +1,25 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once 'tests/UtilsTest.php'; | ||
4 | |||
5 | |||
6 | class UtilsDeTest extends UtilsTest | ||
7 | { | ||
8 | /** | ||
9 | * Test date_format(). | ||
10 | */ | ||
11 | public function testDateFormat() | ||
12 | { | ||
13 | $date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
14 | $this->assertRegExp('/1. Januar 2017 (um )?10:11:12 GMT\+0?3(:00)?/', format_date($date, true)); | ||
15 | } | ||
16 | |||
17 | /** | ||
18 | * Test date_format() using builtin PHP function strftime. | ||
19 | */ | ||
20 | public function testDateFormatDefault() | ||
21 | { | ||
22 | $date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
23 | $this->assertEquals('So 01 Jan 2017 10:11:12 EAT', format_date($date, false)); | ||
24 | } | ||
25 | } | ||
diff --git a/tests/languages/en/UtilsEnTest.php b/tests/languages/en/UtilsEnTest.php new file mode 100644 index 00000000..60bcb653 --- /dev/null +++ b/tests/languages/en/UtilsEnTest.php | |||
@@ -0,0 +1,25 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once 'tests/UtilsTest.php'; | ||
4 | |||
5 | |||
6 | class UtilsEnTest extends UtilsTest | ||
7 | { | ||
8 | /** | ||
9 | * Test date_format(). | ||
10 | */ | ||
11 | public function testDateFormat() | ||
12 | { | ||
13 | $date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
14 | $this->assertRegExp('/January 1, 2017 (at )?10:11:12 AM GMT\+0?3(:00)?/', format_date($date, true)); | ||
15 | } | ||
16 | |||
17 | /** | ||
18 | * Test date_format() using builtin PHP function strftime. | ||
19 | */ | ||
20 | public function testDateFormatDefault() | ||
21 | { | ||
22 | $date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
23 | $this->assertEquals('Sun 01 Jan 2017 10:11:12 AM EAT', format_date($date, false)); | ||
24 | } | ||
25 | } | ||
diff --git a/tests/languages/fr/UtilsFrTest.php b/tests/languages/fr/UtilsFrTest.php new file mode 100644 index 00000000..890308d3 --- /dev/null +++ b/tests/languages/fr/UtilsFrTest.php | |||
@@ -0,0 +1,25 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once 'tests/UtilsTest.php'; | ||
4 | |||
5 | |||
6 | class UtilsFrTest extends UtilsTest | ||
7 | { | ||
8 | /** | ||
9 | * Test date_format(). | ||
10 | */ | ||
11 | public function testDateFormat() | ||
12 | { | ||
13 | $date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
14 | $this->assertRegExp('/1 janvier 2017 (à )?10:11:12 UTC\+0?3(:00)?/', format_date($date)); | ||
15 | } | ||
16 | |||
17 | /** | ||
18 | * Test date_format() using builtin PHP function strftime. | ||
19 | */ | ||
20 | public function testDateFormatDefault() | ||
21 | { | ||
22 | $date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); | ||
23 | $this->assertEquals('dim. 01 janv. 2017 10:11:12 EAT', format_date($date, false)); | ||
24 | } | ||
25 | } | ||