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

Function LocateZone

cpp/src/arrow/compute/kernels/temporal_internal.cc:22–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20namespace arrow::compute::internal {
21
22Result<ArrowTimeZone> LocateZone(const std::string_view timezone) {
23 if (timezone[0] == '+' || timezone[0] == '-') {
24 // Valid offset strings have to have 4 digits and a sign prefix.
25 // Valid examples: +01:23 and -0123.
26 // Invalid examples: 1:23, 123, 0123, 01:23, +25:00, -12:34:45, +090000.
27 auto offset = std::string(timezone.substr(1));
28 std::chrono::minutes zone_offset;
29 switch (timezone.length()) {
30 case 6:
31 if (arrow::internal::detail::ParseHH_MM(offset.c_str(), &zone_offset)) {
32 break;
33 }
34 [[fallthrough]];
35 case 5:
36 if (arrow::internal::detail::ParseHHMM(offset.c_str(), &zone_offset)) {
37 break;
38 }
39 [[fallthrough]];
40 default:
41 return Status::Invalid("Cannot locate or parse timezone '", timezone, "'");
42 }
43 zone_offset = timezone[0] == '-' ? -zone_offset : zone_offset;
44 return OffsetZone(zone_offset);
45 }
46
47 try {
48 return locate_zone(timezone);
49 } catch (const std::runtime_error& ex) {
50 return Status::Invalid("Cannot locate or parse timezone '", timezone,
51 "': ", ex.what());
52 }
53}
54
55} // namespace arrow::compute::internal

Callers

nothing calls this directly

Calls 8

ParseHH_MMFunction · 0.85
ParseHHMMFunction · 0.85
OffsetZoneClass · 0.85
locate_zoneFunction · 0.85
substrMethod · 0.80
whatMethod · 0.80
InvalidFunction · 0.50
lengthMethod · 0.45

Tested by

no test coverage detected