MCPcopy Create free account
hub / github.com/apache/impala / ToUnixTime

Method ToUnixTime

be/src/runtime/timestamp-value.inline.h:193–208  ·  view source on GitHub ↗

Converts to Unix time (seconds since the Unix epoch) representation. Returns false if the conversion failed (unix_time will be undefined), otherwise true.

Source from the content-addressed store, hash-verified

191/// Returns false if the conversion failed (unix_time will be undefined), otherwise
192/// true.
193inline bool TimestampValue::ToUnixTime(const Timezone* local_tz,
194 time_t* unix_time) const {
195 DCHECK(unix_time != nullptr);
196 if (UNLIKELY(!HasDateAndTime())) return false;
197
198 if (local_tz == UTCPTR) {
199 return UtcToUnixTime(unix_time);
200 }
201
202 cctz::civil_second cs(date_.year(), date_.month(), date_.day(), time_.hours(),
203 time_.minutes(), time_.seconds());
204 cctz::time_point<cctz::sys_seconds> tp = cctz::convert(cs, *local_tz);
205 cctz::sys_seconds seconds = tp.time_since_epoch();
206 *unix_time = seconds.count();
207 return true;
208}
209
210/// Converts to Unix time with fractional seconds. The time zone interpretation of the
211/// TimestampValue instance is determined as above.

Callers 4

UnixMethod · 0.80
UnixFromStringMethod · 0.80
TESTFunction · 0.80
mainFunction · 0.80

Calls 4

yearMethod · 0.80
monthMethod · 0.80
dayMethod · 0.80
countMethod · 0.45

Tested by 1

TESTFunction · 0.64