MCPcopy Create free account
hub / github.com/apache/arrow / ParseYYYY_MM_DD

Function ParseYYYY_MM_DD

cpp/src/arrow/util/value_parsing.h:638–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

636
637template <typename Duration>
638static 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
664static inline bool ParseTimestampISO8601(const char* s, size_t length,
665 TimeUnit::type unit, TimestampType::c_type* out,

Callers 3

ParseTimestampISO8601Function · 0.85
ConvertMethod · 0.85
CallMethod · 0.85

Calls 2

ParseUnsignedFunction · 0.85
okMethod · 0.45

Tested by

no test coverage detected