| 660 | } |
| 661 | |
| 662 | void |
| 663 | test_p() |
| 664 | { |
| 665 | using namespace date; |
| 666 | using namespace std::chrono; |
| 667 | using date::sys_time; |
| 668 | { |
| 669 | std::istringstream in{"2016-12-11 11pm"}; |
| 670 | sys_time<hours> tp; |
| 671 | in >> parse("%F %I%p", tp); |
| 672 | assert(!in.fail()); |
| 673 | assert(!in.bad()); |
| 674 | assert(tp == sys_days{2016_y/12/11} + hours{23}); |
| 675 | } |
| 676 | { |
| 677 | std::istringstream in{"1986-12-01 01:01:01 pm"}; |
| 678 | sys_time<seconds> tp; |
| 679 | in >> parse("%Y-%m-%d %I:%M:%S %p", tp); |
| 680 | assert(!in.fail()); |
| 681 | assert(!in.bad()); |
| 682 | assert(tp == sys_days{1986_y/12/01} + hours{13} + minutes{01} + seconds{01}); |
| 683 | } |
| 684 | { |
| 685 | std::istringstream in{"1986-12-01 01:01:01"}; |
| 686 | sys_time<seconds> tp; |
| 687 | in >> parse("%Y-%m-%d %I:%M:%S", tp); |
| 688 | // The test will fail because %I needs the %p option to shows if it is AM or PM |
| 689 | assert(in.fail()); |
| 690 | } |
| 691 | } |
| 692 | |
| 693 | void |
| 694 | test_r() |