| 601 | } |
| 602 | |
| 603 | void |
| 604 | test_T() |
| 605 | { |
| 606 | using namespace date; |
| 607 | using namespace std::chrono; |
| 608 | using date::sys_time; |
| 609 | { |
| 610 | std::istringstream in{"2016-12-11 15:43:22"}; |
| 611 | sys_seconds tp; |
| 612 | in >> parse("%F %T", tp); |
| 613 | assert(!in.fail()); |
| 614 | assert(!in.bad()); |
| 615 | assert(tp == sys_days{2016_y/12/11} + hours{15} + minutes{43} + seconds{22}); |
| 616 | } |
| 617 | { |
| 618 | std::istringstream in{"2016-12-11 15:43:22.001"}; |
| 619 | sys_time<milliseconds> tp; |
| 620 | in >> parse("%F %T", tp); |
| 621 | assert(!in.fail()); |
| 622 | assert(!in.bad()); |
| 623 | assert(tp == sys_days{2016_y/12/11} + hours{15} + minutes{43} + seconds{22} + |
| 624 | milliseconds{1}); |
| 625 | } |
| 626 | { |
| 627 | std::istringstream in{"2016-12-11 15:43:22"}; |
| 628 | sys_time<milliseconds> tp; |
| 629 | in >> parse("%F %T", tp); |
| 630 | assert(!in.fail()); |
| 631 | assert(!in.bad()); |
| 632 | assert(tp == sys_days{2016_y/12/11} + hours{15} + minutes{43} + seconds{22}); |
| 633 | } |
| 634 | { |
| 635 | std::istringstream in{"15:43:22.001"}; |
| 636 | milliseconds d; |
| 637 | in >> parse("%T", d); |
| 638 | assert(!in.fail()); |
| 639 | assert(!in.bad()); |
| 640 | assert(d == hours{15} + minutes{43} + seconds{22} + milliseconds{1}); |
| 641 | } |
| 642 | { |
| 643 | std::istringstream in{"2016-12-11 24:43:22"}; |
| 644 | sys_seconds tp; |
| 645 | in >> parse("%F %T", tp); |
| 646 | assert(in.fail()); |
| 647 | } |
| 648 | { |
| 649 | std::istringstream in{"2016-12-11 15:60:22"}; |
| 650 | sys_seconds tp; |
| 651 | in >> parse("%F %T", tp); |
| 652 | assert(in.fail()); |
| 653 | } |
| 654 | { |
| 655 | std::istringstream in{"2016-12-11 15:43:60"}; |
| 656 | sys_seconds tp; |
| 657 | in >> parse("%F %T", tp); |
| 658 | assert(in.fail()); |
| 659 | } |
| 660 | } |