MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / FindTimeBreakdown

Function FindTimeBreakdown

runtime/standard/time_functions.cc:40–71  ·  view source on GitHub ↗

Timestamp

Source from the content-addressed store, hash-verified

38
39// Timestamp
40absl::Status FindTimeBreakdown(absl::Time timestamp, absl::string_view tz,
41 absl::TimeZone::CivilInfo* breakdown) {
42 absl::TimeZone time_zone;
43
44 // Early return if there is no timezone.
45 if (tz.empty()) {
46 *breakdown = time_zone.At(timestamp);
47 return absl::OkStatus();
48 }
49
50 // Check to see whether the timezone is an IANA timezone.
51 if (absl::LoadTimeZone(tz, &time_zone)) {
52 *breakdown = time_zone.At(timestamp);
53 return absl::OkStatus();
54 }
55
56 // Check for times of the format: [+-]HH:MM and convert them into durations
57 // specified as [+-]HHhMMm.
58 if (absl::StrContains(tz, ":")) {
59 std::string dur = absl::StrCat(tz, "m");
60 absl::StrReplaceAll({{":", "h"}}, &dur);
61 absl::Duration d;
62 if (absl::ParseDuration(dur, &d)) {
63 timestamp += d;
64 *breakdown = time_zone.At(timestamp);
65 return absl::OkStatus();
66 }
67 }
68
69 // Otherwise, error.
70 return absl::InvalidArgumentError("Invalid timezone");
71}
72
73Value GetTimeBreakdownPart(
74 absl::Time timestamp, absl::string_view tz,

Callers 1

GetTimeBreakdownPartFunction · 0.85

Calls 2

ParseDurationFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected