| 636 | |
| 637 | template <typename Duration> |
| 638 | static inline bool ParseYYYY_MM_DD(const char* s, Duration* since_epoch) { |
| 639 | uint16_t year = 0; |
| 640 | uint8_t month = 0; |
| 641 | uint8_t day = 0; |
| 642 | if (ARROW_PREDICT_FALSE(s[4] != '-') || ARROW_PREDICT_FALSE(s[7] != '-')) { |
| 643 | return false; |
| 644 | } |
| 645 | if (ARROW_PREDICT_FALSE(!ParseUnsigned(s + 0, 4, &year))) { |
| 646 | return false; |
| 647 | } |
| 648 | if (ARROW_PREDICT_FALSE(!ParseUnsigned(s + 5, 2, &month))) { |
| 649 | return false; |
| 650 | } |
| 651 | if (ARROW_PREDICT_FALSE(!ParseUnsigned(s + 8, 2, &day))) { |
| 652 | return false; |
| 653 | } |
| 654 | arrow_vendored::date::year_month_day ymd{arrow_vendored::date::year{year}, |
| 655 | arrow_vendored::date::month{month}, |
| 656 | arrow_vendored::date::day{day}}; |
| 657 | if (ARROW_PREDICT_FALSE(!ymd.ok())) return false; |
| 658 | |
| 659 | *since_epoch = std::chrono::duration_cast<Duration>( |
| 660 | arrow_vendored::date::sys_days{ymd}.time_since_epoch()); |
| 661 | return true; |
| 662 | } |
| 663 | |
| 664 | static inline bool ParseTimestampISO8601(const char* s, size_t length, |
| 665 | TimeUnit::type unit, TimestampType::c_type* out, |
no test coverage detected