Hegel 0.18.3
Property-based testing for C++
Loading...
Searching...
No Matches
temporal_types.h
1#pragma once
2
3#include <algorithm>
4#include <array>
5#include <chrono>
6#include <cstddef>
7#include <cstdint>
8#include <functional>
9#include <limits>
10#include <optional>
11#include <ostream>
12#include <ratio>
13#include <string>
14#include <string_view>
15#include <tuple>
16#include <type_traits>
17#include <utility>
18#include <vector>
19
68
70 inline constexpr int32_t MIN_YEAR = -999'999;
72 inline constexpr int32_t MAX_YEAR = 999'999;
74 inline constexpr int64_t MIN_INSTANT = -31'619'087'596'800;
76 inline constexpr int64_t MAX_INSTANT = 31'494'784'780'799;
78 inline constexpr int32_t MAX_OFFSET = 93'599;
81 inline constexpr std::string_view UNKNOWN_ZONE = "Etc/Unknown";
82
84 namespace detail {
85
86 inline constexpr int64_t nanos_per_second = 1'000'000'000;
87
88 // The length of a chrono period in nanoseconds. The period must be
89 // a whole number of nanoseconds that divides a second or is a
90 // multiple of one, which every standard unit is.
91 template <typename Period> struct period_nanos {
92 using ratio = std::ratio_divide<Period, std::nano>;
93 static_assert(ratio::den == 1,
94 "the period must be a whole number of nanoseconds");
95 static constexpr int64_t value = ratio::num;
96 static_assert(value >= nanos_per_second
97 ? value % nanos_per_second == 0
98 : nanos_per_second % value == 0,
99 "the period must divide a second or be a multiple "
100 "of one");
101 };
102
103 // The count of `unit_nanos`-nanosecond units in `seconds` plus
104 // `nanos`, or nullopt when that is not a whole number or does not
105 // fit in int64_t. `nanos` is within one second of zero, of either
106 // sign.
107 std::optional<int64_t> units_from_parts(int64_t seconds, int64_t nanos,
108 int64_t unit_nanos);
109
110 // As units_from_parts, for a count that is not negative and fits
111 // in uint64_t.
112 std::optional<uint64_t> unsigned_units_from_parts(int64_t seconds,
113 int64_t nanos,
114 int64_t unit_nanos);
115
116 // The seconds and nanoseconds of `count` units of `unit_nanos`
117 // nanoseconds, the nanoseconds of the sign of `count` or, with
118 // `floor`, non-negative; nullopt when the seconds do not fit in
119 // int64_t.
120 std::optional<std::pair<int64_t, int64_t>>
121 parts_from_units(int64_t count, int64_t unit_nanos, bool floor);
122
123 // As parts_from_units, for a count of any uint64_t value.
124 std::optional<std::pair<int64_t, int64_t>>
125 parts_from_unsigned_units(uint64_t count, int64_t unit_nanos);
126
127 template <typename Duration>
128 std::optional<Duration> duration_from_parts(int64_t seconds,
129 int64_t nanos) {
130 using Rep = typename Duration::rep;
131 static_assert(std::is_integral_v<Rep>,
132 "a chrono conversion needs an integral Rep");
133 constexpr int64_t unit_nanos =
134 period_nanos<typename Duration::period>::value;
135 if constexpr (std::is_unsigned_v<Rep>) {
136 std::optional<uint64_t> count =
137 unsigned_units_from_parts(seconds, nanos, unit_nanos);
138 if (!count || *count > std::numeric_limits<Rep>::max()) {
139 return std::nullopt;
140 }
141 return Duration(static_cast<Rep>(*count));
142 } else {
143 std::optional<int64_t> count =
144 units_from_parts(seconds, nanos, unit_nanos);
145 if (!count || *count < std::numeric_limits<Rep>::min() ||
146 *count > std::numeric_limits<Rep>::max()) {
147 return std::nullopt;
148 }
149 return Duration(static_cast<Rep>(*count));
150 }
151 }
152
153 template <typename Rep, typename Period>
154 std::optional<std::pair<int64_t, int64_t>>
155 parts_from_duration(std::chrono::duration<Rep, Period> d, bool floor) {
156 static_assert(std::is_integral_v<Rep>,
157 "a chrono conversion needs an integral Rep");
158 if constexpr (std::is_unsigned_v<Rep>) {
159 return parts_from_unsigned_units(
160 static_cast<uint64_t>(d.count()),
161 period_nanos<Period>::value);
162 } else {
163 return parts_from_units(static_cast<int64_t>(d.count()),
164 period_nanos<Period>::value, floor);
165 }
166 }
167
168 template <typename T> struct is_system_time_point : std::false_type {};
169 template <typename Duration>
170 struct is_system_time_point<
171 std::chrono::time_point<std::chrono::system_clock, Duration>>
172 : std::true_type {};
173
174 // Whether period_nanos accepts the period.
175 template <typename Period> struct is_instant_period {
176 using ratio = std::ratio_divide<Period, std::nano>;
177 static constexpr bool value =
178 ratio::den == 1 && (ratio::num >= nanos_per_second
179 ? ratio::num % nanos_per_second == 0
180 : nanos_per_second % ratio::num == 0);
181 };
182
183 // Whether `T` is a system_clock time point that converts to and
184 // from Instant: one that counts, in an integer of at most 64
185 // bits, a period that period_nanos accepts.
186 template <typename T> struct holds_instants : std::false_type {};
187 template <typename Rep, typename Period>
188 struct holds_instants<std::chrono::time_point<
189 std::chrono::system_clock, std::chrono::duration<Rep, Period>>>
190 : std::integral_constant<bool,
191 std::is_integral_v<Rep> &&
192 sizeof(Rep) <= sizeof(int64_t) &&
193 is_instant_period<Period>::value> {};
194
195 } // namespace detail
197
205 struct Date {
206 int32_t year = 1970;
207 uint8_t month = 1;
208 uint8_t day = 1;
209
223 template <typename YearMonthDay>
224 std::optional<YearMonthDay> to_chrono() const {
225 using Year = decltype(std::declval<const YearMonthDay&>().year());
226 using Month = decltype(std::declval<const YearMonthDay&>().month());
227 using Day = decltype(std::declval<const YearMonthDay&>().day());
228 if (year < static_cast<int>((Year::min)()) ||
229 year > static_cast<int>((Year::max)())) {
230 return std::nullopt;
231 }
232 return YearMonthDay{Year{year}, Month{month}, Day{day}};
233 }
234
244 template <typename YearMonthDay>
245 static std::optional<Date> from_chrono(const YearMonthDay& ymd) {
246 if (!ymd.ok()) {
247 return std::nullopt;
248 }
249 return Date{
250 static_cast<int32_t>(static_cast<int>(ymd.year())),
251 static_cast<uint8_t>(static_cast<unsigned>(ymd.month())),
252 static_cast<uint8_t>(static_cast<unsigned>(ymd.day()))};
253 }
254 };
255
263 struct Time {
264 uint8_t hour = 0;
265 uint8_t minute = 0;
266 uint8_t second = 0;
267 uint32_t nanosecond = 0;
268 };
269
274 struct DateTime {
275 Date date;
276 Time time;
277 };
278
288 struct Instant {
289 int64_t second = 0;
290 uint32_t nanosecond = 0;
291
313 template <typename Duration>
314 std::optional<
315 std::chrono::time_point<std::chrono::system_clock, Duration>>
316 to_chrono() const {
317 std::optional<Duration> since_epoch =
318 detail::duration_from_parts<Duration>(second, nanosecond);
319 if (!since_epoch) {
320 return std::nullopt;
321 }
322 return std::chrono::time_point<std::chrono::system_clock, Duration>(
323 *since_epoch);
324 }
325
334 template <typename Rep, typename Period>
335 static std::optional<Instant>
336 from_chrono(std::chrono::time_point<std::chrono::system_clock,
337 std::chrono::duration<Rep, Period>>
338 time_point) {
339 std::optional<std::pair<int64_t, int64_t>> parts =
340 detail::parts_from_duration(time_point.time_since_epoch(),
341 /*floor=*/true);
342 if (!parts || parts->first < MIN_INSTANT ||
343 parts->first > MAX_INSTANT) {
344 return std::nullopt;
345 }
346 return Instant{parts->first, static_cast<uint32_t>(parts->second)};
347 }
348 };
349
359 struct UtcOffset {
360 int32_t seconds = 0;
361 bool known = true;
362 };
363
365 inline constexpr UtcOffset UNKNOWN_OFFSET{0, false};
366
375 struct TimeZone {
376 std::string name;
377 std::string primary_name;
378 };
379
386
412
421 int64_t seconds = 0;
422 int32_t nanoseconds = 0;
423
433 template <typename Duration = std::chrono::nanoseconds>
434 std::optional<Duration> to_chrono() const {
435 return detail::duration_from_parts<Duration>(seconds, nanoseconds);
436 }
437
445 template <typename Rep, typename Period>
446 static std::optional<SignedDuration>
447 from_chrono(std::chrono::duration<Rep, Period> duration) {
448 std::optional<std::pair<int64_t, int64_t>> parts =
449 detail::parts_from_duration(duration, /*floor=*/false);
450 if (!parts) {
451 return std::nullopt;
452 }
453 return SignedDuration{parts->first,
454 static_cast<int32_t>(parts->second)};
455 }
456 };
457
471
479
492 struct Span {
493 int64_t years = 0;
494 int64_t months = 0;
495 int64_t weeks = 0;
496 int64_t days = 0;
497 int64_t hours = 0;
498 int64_t minutes = 0;
499 int64_t seconds = 0;
500 int64_t milliseconds = 0;
501 int64_t microseconds = 0;
502 int64_t nanoseconds = 0;
503
507 int64_t get(SpanUnit unit) const;
508 };
509
511 namespace detail {
512
513 // The fields a value type compares, orders and hashes by, in order
514 // of significance.
515 constexpr auto key(const Date& v) {
516 return std::tie(v.year, v.month, v.day);
517 }
518 constexpr auto key(const Time& v) {
519 return std::tie(v.hour, v.minute, v.second, v.nanosecond);
520 }
521 constexpr auto key(const DateTime& v) {
522 return std::tuple_cat(key(v.date), key(v.time));
523 }
524 constexpr auto key(const Instant& v) {
525 return std::tie(v.second, v.nanosecond);
526 }
527 constexpr std::tuple<bool, int32_t> key(const UtcOffset& v) {
528 return {v.known, v.known ? v.seconds : 0};
529 }
530 constexpr auto key(const TimeZone& v) {
531 return std::tie(v.name, v.primary_name);
532 }
533 constexpr auto key(const ZonedDateTime& v) {
534 return std::tuple_cat(key(v.instant), key(v.zone), key(v.civil),
535 std::tie(v.kind, v.fold),
536 key(v.offset_before), key(v.offset_after),
537 key(v.offset));
538 }
539 constexpr auto key(const SignedDuration& v) {
540 return std::tie(v.seconds, v.nanoseconds);
541 }
542 constexpr auto key(const Span& v) {
543 return std::tie(v.years, v.months, v.weeks, v.days, v.hours,
544 v.minutes, v.seconds, v.milliseconds,
545 v.microseconds, v.nanoseconds);
546 }
547
548 template <typename T, typename = void>
549 struct is_value : std::false_type {};
550 template <typename T>
551 struct is_value<
552 T, std::void_t<decltype(detail::key(std::declval<const T&>()))>>
553 : std::true_type {};
554
555 // `R` when `T` is one of the nine value types.
556 template <typename T, typename R>
557 using if_value = std::enable_if_t<is_value<T>::value, R>;
558
559 template <typename F>
560 void hash_field(std::size_t& seed, const F& field) {
561 seed ^= std::hash<F>{}(field) +
562 static_cast<std::size_t>(0x9e3779b97f4a7c15ULL) +
563 (seed << 6) + (seed >> 2);
564 }
565
566 template <typename T> struct value_hash {
567 std::size_t operator()(const T& value) const noexcept {
568 std::size_t seed = 0;
569 std::apply(
570 [&seed](const auto&... field) {
571 (hash_field(seed, field), ...);
572 },
573 key(value));
574 return seed;
575 }
576 };
577
578 } // namespace detail
580
598
604 template <typename T>
605 constexpr detail::if_value<T, bool> operator==(const T& a, const T& b) {
606 return detail::key(a) == detail::key(b);
607 }
608
613 template <typename T>
614 constexpr detail::if_value<T, bool> operator!=(const T& a, const T& b) {
615 return !(a == b);
616 }
617
622 template <typename T>
623 constexpr detail::if_value<T, bool> operator<(const T& a, const T& b) {
624 return detail::key(a) < detail::key(b);
625 }
626
631 template <typename T>
632 constexpr detail::if_value<T, bool> operator>(const T& a, const T& b) {
633 return b < a;
634 }
635
640 template <typename T>
641 constexpr detail::if_value<T, bool> operator<=(const T& a, const T& b) {
642 return !(b < a);
643 }
644
649 template <typename T>
650 constexpr detail::if_value<T, bool> operator>=(const T& a, const T& b) {
651 return !(a < b);
652 }
653
654
663
668 std::string to_string(const Date& date);
672 std::string to_string(const Time& time);
676 std::string to_string(const DateTime& datetime);
680 std::string to_string(const Instant& instant);
684 std::string to_string(const UtcOffset& offset);
688 std::string to_string(const TimeZone& zone);
694 std::string to_string(const ZonedDateTime& zoned);
698 std::string to_string(const SignedDuration& duration);
702 std::string to_string(const Span& span);
703
709 template <typename T>
710 detail::if_value<T, std::ostream&> operator<<(std::ostream& os,
711 const T& value) {
712 return os << to_string(value);
713 }
714
715
726
734
745
761
764 enum class Ambiguous {
769 };
770
778
817
825
827 struct ZoneInfo {
830 std::string primary_name;
832 bool is_link = false;
834 uint16_t rank = 0;
836 std::vector<Tag> tags;
837
841 bool has(Tag tag) const {
842 return std::find(tags.begin(), tags.end(), tag) != tags.end();
843 }
844 };
845
848
853 inline bool operator==(const ZoneInfo& a, const ZoneInfo& b) {
854 return a.primary_name == b.primary_name && a.is_link == b.is_link &&
855 a.rank == b.rank && a.tags == b.tags;
856 }
857
861 inline bool operator!=(const ZoneInfo& a, const ZoneInfo& b) {
862 return !(a == b);
863 }
864
865
867 struct ZoneOffset {
871 bool is_dst = false;
874 std::string abbreviation;
875 };
876
879
884 inline bool operator==(const ZoneOffset& a, const ZoneOffset& b) {
885 return a.offset == b.offset && a.is_dst == b.is_dst &&
887 }
888
892 inline bool operator!=(const ZoneOffset& a, const ZoneOffset& b) {
893 return !(a == b);
894 }
895
896
907 std::string tzdb_version();
908
920 std::optional<ZoneInfo> info(std::string_view name);
921
936 ZonedDateTime resolve(std::string_view name, const DateTime& civil);
937
947 ZoneOffset offset_at(std::string_view name, const Instant& instant);
948
949} // namespace hegel::generators::temporal
950
952namespace std {
953
954 template <>
956 : hegel::generators::temporal::detail::value_hash<
957 hegel::generators::temporal::Date> {};
958 template <>
960 : hegel::generators::temporal::detail::value_hash<
961 hegel::generators::temporal::Time> {};
962 template <>
963 struct hash<hegel::generators::temporal::DateTime>
964 : hegel::generators::temporal::detail::value_hash<
965 hegel::generators::temporal::DateTime> {};
966 template <>
967 struct hash<hegel::generators::temporal::Instant>
968 : hegel::generators::temporal::detail::value_hash<
969 hegel::generators::temporal::Instant> {};
970 template <>
971 struct hash<hegel::generators::temporal::UtcOffset>
972 : hegel::generators::temporal::detail::value_hash<
973 hegel::generators::temporal::UtcOffset> {};
974 template <>
975 struct hash<hegel::generators::temporal::TimeZone>
976 : hegel::generators::temporal::detail::value_hash<
977 hegel::generators::temporal::TimeZone> {};
978 template <>
979 struct hash<hegel::generators::temporal::ZonedDateTime>
980 : hegel::generators::temporal::detail::value_hash<
981 hegel::generators::temporal::ZonedDateTime> {};
982 template <>
983 struct hash<hegel::generators::temporal::SignedDuration>
984 : hegel::generators::temporal::detail::value_hash<
985 hegel::generators::temporal::SignedDuration> {};
986 template <>
987 struct hash<hegel::generators::temporal::Span>
988 : hegel::generators::temporal::detail::value_hash<
989 hegel::generators::temporal::Span> {};
990
991} // namespace std
Date and time generators, and the plain values they draw.
Definition temporal.h:17
detail::if_value< T, std::ostream & > operator<<(std::ostream &os, const T &value)
Definition temporal_types.h:710
constexpr detail::if_value< T, bool > operator!=(const T &a, const T &b)
Definition temporal_types.h:614
constexpr detail::if_value< T, bool > operator<=(const T &a, const T &b)
Definition temporal_types.h:641
constexpr UtcOffset UNKNOWN_OFFSET
The unknown offset, RFC 3339's -00:00.
Definition temporal_types.h:365
constexpr std::array< Tag, 16 > ALL_TAGS
Every Tag, in the order of the engine's bit set.
Definition temporal_types.h:819
TransitionKind
How a wall-clock time maps to instants in its zone.
Definition temporal_types.h:381
@ Gap
None: the clocks skipped it.
Definition temporal_types.h:383
@ Fold
Two: the clocks repeated it.
Definition temporal_types.h:384
@ Unique
Exactly one instant.
Definition temporal_types.h:382
SpanSign
How the signs of a span's units are drawn.
Definition temporal_types.h:772
@ NonNegative
Definition temporal_types.h:775
@ Mixed
Each unit signed on its own.
Definition temporal_types.h:774
@ Uniform
One sign for every unit.
Definition temporal_types.h:773
constexpr detail::if_value< T, bool > operator>(const T &a, const T &b)
Definition temporal_types.h:632
constexpr int32_t MAX_OFFSET
The largest magnitude of a known UtcOffset in seconds, 25:59:59.
Definition temporal_types.h:78
constexpr int32_t MAX_YEAR
The highest year of a Date.
Definition temporal_types.h:72
constexpr int32_t MIN_YEAR
The lowest year of a Date.
Definition temporal_types.h:70
constexpr int64_t MIN_INSTANT
The first second of MIN_YEAR, the lowest second of an Instant.
Definition temporal_types.h:74
Weekday
A day of the week, for restricting a date draw.
Definition temporal_types.h:736
@ Tuesday
Tuesday.
Definition temporal_types.h:738
@ Monday
Monday.
Definition temporal_types.h:737
@ Thursday
Thursday.
Definition temporal_types.h:740
@ Wednesday
Wednesday.
Definition temporal_types.h:739
@ Saturday
Saturday.
Definition temporal_types.h:742
@ Sunday
Sunday.
Definition temporal_types.h:743
@ Friday
Friday.
Definition temporal_types.h:741
std::optional< ZoneInfo > info(std::string_view name)
What the default zone source knows about name, matched exactly as the source spells it,...
Tag
A feature of a time zone, derived from its offsets and name.
Definition temporal_types.h:785
@ Legacy
Definition temporal_types.h:811
@ InvertedSign
Definition temporal_types.h:813
@ Dst
Definition temporal_types.h:793
@ Fixed
No transition after 1970.
Definition temporal_types.h:786
@ SameOffset
Definition temporal_types.h:806
@ DstOther
Definition temporal_types.h:795
@ Fractional
Definition temporal_types.h:788
@ Seconds
Definition temporal_types.h:790
@ WholeDay
Definition temporal_types.h:804
@ Link
The name is a link to another zone.
Definition temporal_types.h:810
@ BaseChange
Definition temporal_types.h:798
@ Midnight
Definition temporal_types.h:800
@ Multi
Some calendar year has more than two offset changes.
Definition temporal_types.h:797
@ Undefined
Definition temporal_types.h:808
@ SpansMidnight
Definition temporal_types.h:802
@ WholeHour
Every offset after 1970 is a whole number of hours.
Definition temporal_types.h:787
constexpr int64_t MAX_INSTANT
The last second of MAX_YEAR, the highest second of an Instant.
Definition temporal_types.h:76
Month
A month of the year, for restricting a date draw.
Definition temporal_types.h:747
@ May
May.
Definition temporal_types.h:752
@ July
July.
Definition temporal_types.h:754
@ April
April.
Definition temporal_types.h:751
@ August
August.
Definition temporal_types.h:755
@ February
February.
Definition temporal_types.h:749
@ June
June.
Definition temporal_types.h:753
@ November
November.
Definition temporal_types.h:758
@ December
December.
Definition temporal_types.h:759
@ January
January.
Definition temporal_types.h:748
@ September
September.
Definition temporal_types.h:756
@ October
October.
Definition temporal_types.h:757
@ March
March.
Definition temporal_types.h:750
Ambiguous
Definition temporal_types.h:764
@ Both
Definition temporal_types.h:765
@ Later
The later instant, with no fold drawn.
Definition temporal_types.h:768
@ Earlier
The earlier instant, with no fold drawn.
Definition temporal_types.h:767
constexpr std::array< SpanUnit, 10 > ALL_SPAN_UNITS
Every SpanUnit, largest first.
Definition temporal_types.h:473
std::string tzdb_version()
The IANA release of the time zone database bundled in the engine, such as "2026e".
SpanUnit
A unit of a Span, largest first.
Definition temporal_types.h:459
@ Milliseconds
Milliseconds.
Definition temporal_types.h:467
@ Microseconds
Microseconds.
Definition temporal_types.h:468
@ Hours
Hours.
Definition temporal_types.h:464
@ Seconds
Seconds.
Definition temporal_types.h:466
@ Weeks
Weeks.
Definition temporal_types.h:462
@ Years
Calendar years.
Definition temporal_types.h:460
@ Days
Days.
Definition temporal_types.h:463
@ Months
Calendar months.
Definition temporal_types.h:461
@ Minutes
Minutes.
Definition temporal_types.h:465
@ Nanoseconds
Nanoseconds.
Definition temporal_types.h:469
constexpr std::string_view UNKNOWN_ZONE
Definition temporal_types.h:81
Granularity
The values a UTC offset draw restricts itself to.
Definition temporal_types.h:728
@ QuarterHours
Whole quarter hours.
Definition temporal_types.h:730
Precision
Definition temporal_types.h:718
ZonedDateTime resolve(std::string_view name, const DateTime &civil)
Classify the wall-clock time civil in the zone name and resolve it to an instant, meaning the earlier...
constexpr detail::if_value< T, bool > operator>=(const T &a, const T &b)
Definition temporal_types.h:650
std::string to_string(const Date &date)
constexpr detail::if_value< T, bool > operator<(const T &a, const T &b)
Definition temporal_types.h:623
constexpr detail::if_value< T, bool > operator==(const T &a, const T &b)
Definition temporal_types.h:605
ZoneOffset offset_at(std::string_view name, const Instant &instant)
The offset the zone name has in force at instant.
Field< MemberPtr, Gen > field(Gen gen)
Create a field specification for builds_agg().
Definition builds.h:119
Main namespace.
Definition config.h:29
A wall-clock date and time with no zone or offset, in the range of Date and Time. Prints as 2024-03-1...
Definition temporal_types.h:274
A proleptic Gregorian calendar date.
Definition temporal_types.h:205
uint8_t month
The month, 1 for January.
Definition temporal_types.h:207
uint8_t day
The day of the month, from 1.
Definition temporal_types.h:208
int32_t year
The year, negative before year 0.
Definition temporal_types.h:206
An instant.
Definition temporal_types.h:288
A signed duration: seconds plus nanoseconds of the same sign, the latter within ±999999999,...
Definition temporal_types.h:420
int64_t seconds
Whole seconds.
Definition temporal_types.h:421
std::optional< Duration > to_chrono() const
The same duration as a std::chrono::duration, or std::nullopt when it is not a whole number of the du...
Definition temporal_types.h:434
static std::optional< SignedDuration > from_chrono(std::chrono::duration< Rep, Period > duration)
The SignedDuration of a std::chrono::duration, or std::nullopt when its seconds do not fit in int64_t...
Definition temporal_types.h:447
int32_t nanoseconds
Nanoseconds, of the sign of seconds.
Definition temporal_types.h:422
A calendar span: a signed count of each unit from years to nanoseconds, never normalised (90 minutes ...
Definition temporal_types.h:492
int64_t microseconds
Microseconds.
Definition temporal_types.h:501
int64_t hours
Hours.
Definition temporal_types.h:497
int64_t nanoseconds
Nanoseconds.
Definition temporal_types.h:502
int64_t weeks
Weeks.
Definition temporal_types.h:495
int64_t months
Calendar months.
Definition temporal_types.h:494
int64_t milliseconds
Milliseconds.
Definition temporal_types.h:500
int64_t years
Calendar years.
Definition temporal_types.h:493
int64_t seconds
Seconds.
Definition temporal_types.h:499
int64_t days
Days.
Definition temporal_types.h:496
int64_t get(SpanUnit unit) const
int64_t minutes
Minutes.
Definition temporal_types.h:498
A time zone of a zone source, or UNKNOWN_ZONE.
Definition temporal_types.h:375
std::string name
The name as written.
Definition temporal_types.h:376
std::string primary_name
The zone whose data applies.
Definition temporal_types.h:377
A time of day from 00:00:00 to 23:59:59.999999999.
Definition temporal_types.h:263
A UTC offset: a known number of seconds east of UTC within ±25:59:59 (MAX_OFFSET),...
Definition temporal_types.h:359
int32_t seconds
Seconds east of UTC; 0 when not known.
Definition temporal_types.h:360
bool known
False for the unknown offset.
Definition temporal_types.h:361
What a zone source knows about a time zone name; see info().
Definition temporal_types.h:827
bool has(Tag tag) const
Definition temporal_types.h:841
uint16_t rank
The name's position on the shrink ladder; UTC is 0.
Definition temporal_types.h:834
std::string primary_name
Definition temporal_types.h:830
std::vector< Tag > tags
The zone's features, in ALL_TAGS order.
Definition temporal_types.h:836
bool is_link
Whether the name is a link to primary_name.
Definition temporal_types.h:832
The offset a time zone has in force at an instant; see offset_at().
Definition temporal_types.h:867
bool is_dst
Definition temporal_types.h:871
std::string abbreviation
Definition temporal_types.h:874
UtcOffset offset
Definition temporal_types.h:868
A wall-clock time in a time zone, resolved to an instant.
Definition temporal_types.h:401
UtcOffset offset
The offset in force at instant.
Definition temporal_types.h:409
DateTime civil
Definition temporal_types.h:403
UtcOffset offset_after
The offset after the transition.
Definition temporal_types.h:407
bool fold
Which repeat of a fold is meant.
Definition temporal_types.h:408
Instant instant
The resolved instant.
Definition temporal_types.h:410
UtcOffset offset_before
The offset before the transition.
Definition temporal_types.h:406
TimeZone zone
The zone the wall time is read in.
Definition temporal_types.h:402
TransitionKind kind
How the wall time maps to instants.
Definition temporal_types.h:405