51 std::chrono::system_clock::from_time_t(0));
60 q == std::numeric_limits<int64_t>::min()) ? q : q - 1;
65 bd.
year = std::numeric_limits<int64_t>::max();
82 bd.
year = std::numeric_limits<int64_t>::min();
98 TimeZone::CivilInfo ci;
103 ci.zone_abbr =
"-00";
108 TimeZone::CivilInfo ci;
113 ci.zone_abbr =
"-00";
125 inline TimeConversion InfinitePastTimeConversion() {
138 bool* normalized =
nullptr) {
142 const auto al = tz.
lookup(max);
144 if (normalized) *normalized =
true;
149 const auto al = tz.
lookup(min);
151 if (normalized) *normalized =
true;
155 const auto hi = (sec - unix_epoch()).count();
162 case cctz::weekday::monday:
164 case cctz::weekday::tuesday:
166 case cctz::weekday::wednesday:
168 case cctz::weekday::thursday:
170 case cctz::weekday::friday:
172 case cctz::weekday::saturday:
174 case cctz::weekday::sunday:
183 cctz::time_zone::civil_transition* trans)
const,
184 Time t, TimeZone::CivilTransition* trans) {
187 cctz::time_zone::civil_transition tr;
188 if (!(tz.*find_transition)(tp, &tr))
return false;
206 const auto cs = al.cs;
241 1000 * 1000 * 1000) +
301 ts.tv_sec = std::numeric_limits<time_t>::max();
302 ts.tv_nsec = 1000 * 1000 * 1000 - 1;
304 ts.tv_sec = std::numeric_limits<time_t>::min();
313 tv.tv_sec = ts.tv_sec;
314 if (tv.tv_sec != ts.tv_sec) {
316 tv.tv_sec = std::numeric_limits<decltype(tv.tv_sec)>::min();
319 tv.tv_sec = std::numeric_limits<decltype(tv.tv_sec)>::max();
320 tv.tv_usec = 1000 * 1000 - 1;
324 tv.tv_usec =
static_cast<int>(ts.tv_nsec / 1000);
330 tp - std::chrono::system_clock::from_time_t(0)));
334 using D = std::chrono::system_clock::duration;
337 return std::chrono::system_clock::from_time_t(0) +
338 time_internal::ToChronoDuration<D>(d);
351 const auto al = cz_.lookup(tp);
364 const auto cl = cz_.lookup(cs);
368 case cctz::time_zone::civil_lookup::UNIQUE:
371 case cctz::time_zone::civil_lookup::SKIPPED:
374 case cctz::time_zone::civil_lookup::REPEATED:
378 ti.
pre = MakeTimeWithOverflow(cl.pre, cs, cz_);
379 ti.
trans = MakeTimeWithOverflow(cl.trans, cs, cz_);
380 ti.
post = MakeTimeWithOverflow(cl.post, cs, cz_);
399 if (year > 300000000000)
return InfiniteFutureTimeConversion();
400 if (year < -300000000000)
return InfinitePastTimeConversion();
402 const CivilSecond cs(year, mon, day, hour, min, sec);
403 const auto ti = tz.
At(cs);
421 if (year != cs.
year() || mon != cs.
month() || day != cs.
day() ||
429 const CivilSecond cs(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
430 tm.tm_hour, tm.tm_min, tm.tm_sec);
431 const auto ti = tz.
At(cs);
432 return tm.tm_isdst == 0 ? ti.post : ti.pre;
438 const auto ci = tz.At(t);
439 const auto& cs = ci.cs;
442 tm.tm_hour = cs.
hour();
443 tm.tm_mday = cs.
day();
444 tm.tm_mon = cs.
month() - 1;
448 if (cs.
year() < std::numeric_limits<int>::min() + 1900) {
449 tm.tm_year = std::numeric_limits<int>::min();
450 }
else if (cs.
year() > std::numeric_limits<int>::max()) {
451 tm.tm_year = std::numeric_limits<int>::max() - 1900;
453 tm.tm_year =
static_cast<int>(cs.
year() - 1900);
458 case Weekday::sunday:
461 case Weekday::monday:
464 case Weekday::tuesday:
467 case Weekday::wednesday:
470 case Weekday::thursday:
473 case Weekday::friday:
476 case Weekday::saturday:
481 tm.tm_isdst = ci.is_dst ? 1 : 0;
CivilInfo At(Time t) const
timespec ToTimespec(Duration d)
bool next_transition(const time_point< seconds > &tp, civil_transition *trans) const
CONSTEXPR_F int get_yearday(const civil_day &cd) noexcept
absl::TimeConversion ConvertDateTime(int64_t year, int mon, int day, int hour, int min, int sec, TimeZone tz)
Weekday GetWeekday(CivilDay cd)
CONSTEXPR_M int minute() const noexcept
constexpr Time InfiniteFuture()
absl::Time FromUniversal(int64_t universal)
Duration DurationFromTimespec(timespec ts)
constexpr Duration ToUnixDuration(Time t)
int64_t ToUnixMillis(Time t)
std::chrono::system_clock::time_point ToChronoTime(absl::Time t)
int64_t ToUniversal(absl::Time t)
CONSTEXPR_M int day() const noexcept
int GetYearDay(CivilDay cd)
constexpr Duration Microseconds(int64_t n)
Duration Floor(const Duration d, const Duration unit)
int64_t ToUnixMicros(Time t)
constexpr Time FromUnixDuration(Duration d)
CONSTEXPR_F weekday get_weekday(const civil_day &cd) noexcept
std::chrono::duration< std::int_fast64_t > seconds
detail::civil_day civil_day
constexpr Duration Milliseconds(int64_t n)
static CONSTEXPR_F civil_time() max()
static CONSTEXPR_F civil_time() min()
absl::Time FromTM(const struct tm &tm, absl::TimeZone tz)
timeval ToTimeval(Duration d)
bool NextTransition(Time t, CivilTransition *trans) const
CONSTEXPR_M year_t year() const noexcept
absl::Time TimeFromTimespec(timespec ts)
constexpr Duration MakeDuration(int64_t hi, uint32_t lo)
bool prev_transition(const time_point< seconds > &tp, civil_transition *trans) const
time_internal::cctz::detail::civil_time< time_internal::second_tag > CivilSecond
enum absl::TimeZone::TimeInfo::CivilKind kind
absolute_lookup lookup(const time_point< seconds > &tp) const
CONSTEXPR_M int month() const noexcept
constexpr Duration FromChrono(const std::chrono::duration< Rep, Period > &d)
int64_t IDivDuration(Duration num, Duration den, Duration *rem)
int64_t ToUnixSeconds(Time t)
constexpr Time UniversalEpoch()
absl::Time FromUDate(double udate)
bool PrevTransition(Time t, CivilTransition *trans) const
std::chrono::time_point< std::chrono::system_clock, D > time_point
constexpr uint32_t GetRepLo(Duration d)
CONSTEXPR_M int second() const noexcept
struct tm ToTM(absl::Time t, absl::TimeZone tz)
double FDivDuration(Duration num, Duration den)
constexpr int64_t GetRepHi(Duration d)
Duration DurationFromTimeval(timeval tv)
constexpr Duration Nanoseconds(int64_t n)
CONSTEXPR_M int hour() const noexcept
Breakdown In(TimeZone tz) const
constexpr Duration InfiniteDuration()
constexpr Duration ZeroDuration()
int64_t ToUnixNanos(Time t)
absl::Time TimeFromTimeval(timeval tv)
constexpr Time InfinitePast()
Time FromChrono(const std::chrono::system_clock::time_point &tp)
constexpr bool IsInfiniteDuration(Duration d)