| 1 |
use Test::More tests => 10; |
| 2 |
use Date::Language; |
| 3 |
|
| 4 |
# Tests for language-specific timezone abbreviation translation (issue #1 / RT#52878) |
| 5 |
# When using %Z format with a language object, timezone abbreviations should be |
| 6 |
# translated to the language's local equivalents if the language defines a %TZ mapping. |
| 7 |
|
| 8 |
my $german = Date::Language->new('German'); |
| 9 |
my $english = Date::Language->new('English'); |
| 10 |
|
| 11 |
# Fixed timestamp: 2009-01-01 00:00:00 UTC (standard time, no DST) |
| 12 |
my $t = 1230768000; |
| 13 |
|
| 14 |
# English should return standard English abbreviations unchanged |
| 15 |
is( $english->time2str('%Z', $t, 'CET'), 'CET', 'English: CET stays CET' ); |
| 16 |
is( $english->time2str('%Z', $t, 'CEST'), 'CEST', 'English: CEST stays CEST' ); |
| 17 |
is( $english->time2str('%Z', $t, 'GMT'), 'GMT', 'English: GMT stays GMT' ); |
| 18 |
|
| 19 |
# German should translate CET → MEZ and CEST → MESZ |
| 20 |
is( $german->time2str('%Z', $t, 'CET'), 'MEZ', 'German: CET → MEZ' ); |
| 21 |
is( $german->time2str('%Z', $t, 'CEST'), 'MESZ', 'German: CEST → MESZ' ); |
| 22 |
|
| 23 |
# German: timezones without a translation should pass through unchanged |
| 24 |
is( $german->time2str('%Z', $t, 'GMT'), 'GMT', 'German: GMT passes through (no translation defined)' ); |
| 25 |
is( $german->time2str('%Z', $t, 'UTC'), 'UTC', 'German: UTC passes through (no translation defined)' ); |
| 26 |
|
| 27 |
# German: other European timezone translations |
| 28 |
is( $german->time2str('%Z', $t, 'EET'), 'OEZ', 'German: EET → OEZ' ); |
| 29 |
is( $german->time2str('%Z', $t, 'EEST'), 'OESZ', 'German: EEST → OESZ' ); |
| 30 |
is( $german->time2str('%Z', $t, 'WET'), 'WEZ', 'German: WET → WEZ' ); |