| 1 |
// { dg-do run { target c++20 } } |
| 2 |
// { dg-require-effective-target tzdb } |
| 3 |
|
| 4 |
#include <chrono> |
| 5 |
#include <testsuite_hooks.h> |
| 6 |
|
| 7 |
void |
| 8 |
test_nonexistent() |
| 9 |
{ |
| 10 |
std::string expected |
| 11 |
= "2016-03-13 02:30:00 is in a gap between\n" |
| 12 |
"2016-03-13 02:00:00 EST and\n" |
| 13 |
"2016-03-13 03:00:00 EDT which are both equivalent to\n" |
| 14 |
"2016-03-13 07:00:00 UTC"; |
| 15 |
|
| 16 |
using namespace std::chrono; |
| 17 |
try { |
| 18 |
auto zt = zoned_time{"America/New_York", |
| 19 |
local_days{Sunday[2]/March/2016} + 2h + 30min}; |
| 20 |
VERIFY(false); |
| 21 |
} catch (const nonexistent_local_time& e) { |
| 22 |
VERIFY( e.what() == expected ); |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
void |
| 27 |
test_ambiguous() |
| 28 |
{ |
| 29 |
std::string expected |
| 30 |
= "2016-11-06 01:30:00 is ambiguous. It could be\n" |
| 31 |
"2016-11-06 01:30:00 EDT == 2016-11-06 05:30:00 UTC or\n" |
| 32 |
"2016-11-06 01:30:00 EST == 2016-11-06 06:30:00 UTC"; |
| 33 |
|
| 34 |
using namespace std::chrono; |
| 35 |
try { |
| 36 |
auto zt = zoned_time{"America/New_York", |
| 37 |
local_days{Sunday[1]/November/2016} + 1h + 30min}; |
| 38 |
VERIFY(false); |
| 39 |
} catch (const ambiguous_local_time& e) { |
| 40 |
VERIFY( e.what() == expected ); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
int main() |
| 45 |
{ |
| 46 |
test_nonexistent(); |
| 47 |
test_ambiguous(); |
| 48 |
} |