| 523 | |
| 524 | template <typename Duration> |
| 525 | static 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 | |
| 556 | static inline bool ParseSubSeconds(const char* s, size_t length, TimeUnit::type unit, |
| 557 | uint32_t* out) { |
no test coverage detected