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

Function ParseHH_MM_SS

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

Source from the content-addressed store, hash-verified

523
524template <typename Duration>
525static inline bool ParseHH_MM_SS(const char* s, Duration* out) {
526 uint8_t hours = 0;
527 uint8_t minutes = 0;
528 uint8_t seconds = 0;
529 if (ARROW_PREDICT_FALSE(s[2] != ':') || ARROW_PREDICT_FALSE(s[5] != ':')) {
530 return false;
531 }
532 if (ARROW_PREDICT_FALSE(!ParseUnsigned(s + 0, 2, &hours))) {
533 return false;
534 }
535 if (ARROW_PREDICT_FALSE(!ParseUnsigned(s + 3, 2, &minutes))) {
536 return false;
537 }
538 if (ARROW_PREDICT_FALSE(!ParseUnsigned(s + 6, 2, &seconds))) {
539 return false;
540 }
541 if (ARROW_PREDICT_FALSE(hours >= 24)) {
542 return false;
543 }
544 if (ARROW_PREDICT_FALSE(minutes >= 60)) {
545 return false;
546 }
547 if (ARROW_PREDICT_FALSE(seconds >= 60)) {
548 return false;
549 }
550 *out = std::chrono::duration_cast<Duration>(std::chrono::hours(hours) +
551 std::chrono::minutes(minutes) +
552 std::chrono::seconds(seconds));
553 return true;
554}
555
556static inline bool ParseSubSeconds(const char* s, size_t length, TimeUnit::type unit,
557 uint32_t* out) {

Callers 2

ParseTimestampISO8601Function · 0.85
ConvertMethod · 0.85

Calls 1

ParseUnsignedFunction · 0.85

Tested by

no test coverage detected