| 1 |
// { dg-do run { target c++20 } } |
| 2 |
// { dg-require-effective-target tzdb } |
| 3 |
// { dg-require-effective-target cxx11_abi } |
| 4 |
|
| 5 |
#include <chrono> |
| 6 |
#include <testsuite_hooks.h> |
| 7 |
|
| 8 |
using namespace std::chrono; |
| 9 |
|
| 10 |
void |
| 11 |
test_broken_hill() |
| 12 |
{ |
| 13 |
/* |
| 14 |
R AN 1996 2005 - Mar lastSun 2s 0 S |
| 15 |
R AN 2000 o - Aug lastSun 2s 1 D |
| 16 |
Z Australia/Broken_Hill 9:25:48 - LMT 1895 Feb |
| 17 |
10 - AEST 1896 Aug 23 |
| 18 |
9 - ACST 1899 May |
| 19 |
9:30 AU AC%sT 1971 |
| 20 |
9:30 AN AC%sT 2000 |
| 21 |
9:30 AS AC%sT |
| 22 |
*/ |
| 23 |
auto* tz = locate_zone("Australia/Broken_Hill"); |
| 24 |
auto info = tz->get_info(sys_days(2000y/February/29d) + 23h + 23min + 23s); |
| 25 |
VERIFY( info.offset == 630min ); |
| 26 |
VERIFY( info.save == 60min ); |
| 27 |
VERIFY( info.abbrev == "ACDT" ); |
| 28 |
} |
| 29 |
|
| 30 |
void |
| 31 |
test_kiritimati() |
| 32 |
{ |
| 33 |
/* No named rules involved here, just change of fixed STDOFF at 1994-12-31: |
| 34 |
Z Pacific/Kiritimati -10:29:20 - LMT 1901 |
| 35 |
-10:40 - %z 1979 Oct |
| 36 |
-10 - %z 1994 Dec 31 |
| 37 |
14 - %z |
| 38 |
*/ |
| 39 |
auto* tz = locate_zone("Pacific/Kiritimati"); |
| 40 |
local_seconds t = local_days(1994y/December/31); |
| 41 |
|
| 42 |
sys_seconds ut(t.time_since_epoch() + 10h); |
| 43 |
sys_info info; |
| 44 |
info = tz->get_info(ut - 1s); |
| 45 |
VERIFY( info.offset == -10h ); |
| 46 |
VERIFY( info.save == 0h ); |
| 47 |
VERIFY( info.abbrev == "-10" ); |
| 48 |
info = tz->get_info(ut); |
| 49 |
VERIFY( info.offset == 14h ); |
| 50 |
VERIFY( info.save == 0h ); |
| 51 |
VERIFY( info.abbrev == "+14" ); |
| 52 |
} |
| 53 |
|
| 54 |
void |
| 55 |
test_apia() |
| 56 |
{ |
| 57 |
/* Refers to same named rule before/after change at 2011-12-29 24:00 |
| 58 |
but the offset changed from -11h+1h to +13h+1h |
| 59 |
Z Pacific/Apia 12:33:4 - LMT 1892 Jul 5 |
| 60 |
-11:26:56 - LMT 1911 |
| 61 |
-11:30 - %z 1950 |
| 62 |
-11 WS %z 2011 Dec 29 24 |
| 63 |
13 WS %z |
| 64 |
*/ |
| 65 |
auto* tz = locate_zone("Pacific/Apia"); |
| 66 |
local_seconds t = local_days(2011y/December/29) + 24h; |
| 67 |
|
| 68 |
// FIXME: this should be + 10h but we do not account for DST yet, so + 11h. |
| 69 |
sys_seconds ut(t.time_since_epoch() + 11h ); |
| 70 |
sys_info info; |
| 71 |
info = tz->get_info(ut - 1s); |
| 72 |
VERIFY( info.offset == (-11h + info.save) ); |
| 73 |
VERIFY( info.save == 1h ); |
| 74 |
VERIFY( info.abbrev == "-10" ); |
| 75 |
info = tz->get_info(ut); |
| 76 |
VERIFY( info.offset == (13h + info.save) ); |
| 77 |
VERIFY( info.save == 1h ); |
| 78 |
VERIFY( info.abbrev == "+14" ); |
| 79 |
} |
| 80 |
|
| 81 |
int main() |
| 82 |
{ |
| 83 |
test_broken_hill(); |
| 84 |
test_kiritimati(); |
| 85 |
test_apia(); |
| 86 |
} |