| 244 | } |
| 245 | |
| 246 | TimestampValue 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 | |
| 261 | void TimestampValue::ToString(string& dst) const { |
| 262 | dst.resize(SimpleDateFormatTokenizer::DEFAULT_DATE_TIME_FMT_LEN); |
nothing calls this directly
no test coverage detected