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

Method UnixTimeToLocal

be/src/runtime/timestamp-value.cc:246–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246TimestampValue TimestampValue::UnixTimeToLocal(
247 time_t unix_time, const Timezone& local_tz) {
248 cctz::time_point<cctz::sys_seconds> from_tp = UnixTimeToTimePoint(unix_time);
249 cctz::civil_second to_cs = cctz::convert(from_tp, local_tz);
250 // boost::gregorian::date() throws boost::gregorian::bad_year if year is not in the
251 // 1400..9999 range. Need to check validity before creating the date object.
252 if (UNLIKELY(IsDateOutOfRange(to_cs))) {
253 return ptime(not_a_date_time);
254 } else {
255 return TimestampValue(
256 boost::gregorian::date(to_cs.year(), to_cs.month(), to_cs.day()),
257 boost::posix_time::time_duration(to_cs.hour(), to_cs.minute(), to_cs.second()));
258 }
259}
260
261void TimestampValue::ToString(string& dst) const {
262 dst.resize(SimpleDateFormatTokenizer::DEFAULT_DATE_TIME_FMT_LEN);

Callers

nothing calls this directly

Calls 8

IsDateOutOfRangeFunction · 0.85
time_durationClass · 0.85
yearMethod · 0.80
monthMethod · 0.80
dayMethod · 0.80
hourMethod · 0.80
UnixTimeToTimePointFunction · 0.70
TimestampValueClass · 0.70

Tested by

no test coverage detected