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

Function CastSecondsToUnit

cpp/src/arrow/util/time.h:74–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74inline std::optional<int64_t> CastSecondsToUnit(TimeUnit::type unit, int64_t seconds) {
75 auto cast_seconds_to_unit = [](auto duration,
76 int64_t seconds) -> std::optional<int64_t> {
77 constexpr auto kMultiplier = static_cast<int64_t>(decltype(duration)::period::den);
78 int64_t out;
79 if (ARROW_PREDICT_FALSE(
80 ::arrow::internal::MultiplyWithOverflow(seconds, kMultiplier, &out))) {
81 return {};
82 }
83 return out;
84 };
85 return VisitDuration(unit, cast_seconds_to_unit, seconds);
86}
87
88inline bool CastSecondsToUnit(TimeUnit::type unit, int64_t seconds, int64_t* out) {
89 auto maybe_value = CastSecondsToUnit(unit, seconds);

Callers 3

ParseTimestampISO8601Function · 0.85
ParseTimestampStrptimeFunction · 0.85
ConvertMethod · 0.85

Calls 2

MultiplyWithOverflowFunction · 0.85
VisitDurationFunction · 0.85

Tested by

no test coverage detected