|
| struct | DatesParams |
| | Parameters for dates() generator. More...
|
| struct | TimesParams |
| | Parameters for times() generator. More...
|
| struct | DatetimesParams |
| | Parameters for datetimes() generator. More...
|
| struct | InstantsParams |
| | Parameters for instants() generator over a std::chrono::system_clock time point. More...
|
| struct | InstantsParams< Instant > |
| | Parameters for instants() generator over Instant. More...
|
| struct | OffsetsParams |
| | Parameters for offsets() generator. More...
|
| struct | ZonesParams |
| | Parameters for zones() generator. More...
|
| struct | ZonedDatetimesParams |
| | Parameters for zoned_datetimes() generator. More...
|
| struct | UnitBounds |
| | Inclusive bounds on one unit of a span, for SpansParams. More...
|
| struct | SpansParams |
| | Parameters for spans() generator. More...
|
| struct | DurationsParams |
| | Parameters for durations() generator over a std::chrono::duration. More...
|
| struct | DurationsParams< SignedDuration > |
| | Parameters for durations() generator over SignedDuration. More...
|
| struct | Date |
| | A proleptic Gregorian calendar date. More...
|
| struct | Time |
| | A time of day from 00:00:00 to 23:59:59.999999999. More...
|
| struct | DateTime |
| | A wall-clock date and time with no zone or offset, in the range of Date and Time. Prints as 2024-03-10T02:30:00. More...
|
| struct | Instant |
| | An instant. More...
|
| struct | UtcOffset |
| | A UTC offset: a known number of seconds east of UTC within ±25:59:59 (MAX_OFFSET), or the unknown offset of RFC 3339's -00:00, which the offset and zone draws yield only when asked to. More...
|
| struct | TimeZone |
| | A time zone of a zone source, or UNKNOWN_ZONE. More...
|
| struct | ZonedDateTime |
| | A wall-clock time in a time zone, resolved to an instant. More...
|
| struct | SignedDuration |
| | A signed duration: seconds plus nanoseconds of the same sign, the latter within ±999999999, so -1.5 s is {-1, -500000000}. More...
|
| struct | Span |
| | A calendar span: a signed count of each unit from years to nanoseconds, never normalised (90 minutes is not an hour and a half, and a month is not a number of days). More...
|
| struct | ZoneInfo |
| | What a zone source knows about a time zone name; see info(). More...
|
| struct | ZoneOffset |
| | The offset a time zone has in force at an instant; see offset_at(). More...
|
| struct | ZoneType |
| | A local time type of a zone: an offset, its daylight-saving flag and its abbreviation. More...
|
| struct | ZoneTransition |
| | An explicit transition: from instant on, type is in force. More...
|
| struct | RuleDate |
| | The day and time of day a yearly rule changes the clocks on, as a POSIX TZ string names them (RFC 9636 §3.3.1). More...
|
| struct | DaylightRule |
| | Daylight-saving time of a yearly rule: its type, and the dates it starts and ends on each year. More...
|
| struct | ZoneRule |
| | A yearly rule in force after a zone's explicit transitions: the footer of a TZif file. More...
|
| struct | HoldLast |
| | The last type in force, held for ever after the explicit transitions. More...
|
| struct | InferRule |
| | A yearly rule the engine infers from the transitions of last_year and the year before it. More...
|
| struct | ZoneData |
| | A zone's data given as fields: the TZif model of RFC 9636. More...
|
| struct | ZoneOracle |
| | A library that answers offset lookups but does not expose its zone data, probed into explicit transitions over the years first_year to last_year. More...
|
| class | ZoneSource |
| | A source of time zone data: the database the zone and zoned datetime generators classify, target and resolve wall times against. More...
|
|
| enum class | TransitionKind { Unique
, Gap
, Fold
} |
| | How a wall-clock time maps to instants in its zone. More...
|
| enum class | SpanUnit {
Years
, Months
, Weeks
, Days
,
Hours
, Minutes
, Seconds
, Milliseconds
,
Microseconds
, Nanoseconds
} |
| | A unit of a Span, largest first. More...
|
| enum class | Precision {
Nanoseconds
, Microseconds
, Milliseconds
, Seconds
,
Minutes
, Hours
} |
| enum class | Granularity { Hours
, QuarterHours
, Minutes
, Seconds
} |
| | The values a UTC offset draw restricts itself to. More...
|
| enum class | Weekday {
Monday
, Tuesday
, Wednesday
, Thursday
,
Friday
, Saturday
, Sunday
} |
| | A day of the week, for restricting a date draw. More...
|
| enum class | Month {
January
, February
, March
, April
,
May
, June
, July
, August
,
September
, October
, November
, December
} |
| | A month of the year, for restricting a date draw. More...
|
| enum class | Ambiguous { Both
, Earlier
, Later
} |
| enum class | SpanSign { Uniform
, Mixed
, NonNegative
} |
| | How the signs of a span's units are drawn. More...
|
| enum class | Tag {
Fixed
, WholeHour
, Fractional
, Seconds
,
Dst
, DstOther
, Multi
, BaseChange
,
Midnight
, SpansMidnight
, WholeDay
, SameOffset
,
Undefined
, Link
, Legacy
, InvertedSign
} |
| | A feature of a time zone, derived from its offsets and name. More...
|
| enum class | AfterProbe { Hold
, Infer
} |
|
| Generator< Date > | dates (const DatesParams ¶ms={}) |
| | Generate Date values.
|
| Generator< Time > | times (TimesParams params={}) |
| | Generate Time values.
|
| Generator< DateTime > | datetimes (DatetimesParams params={}) |
| | Generate DateTime values.
|
| Generator< UtcOffset > | offsets (OffsetsParams params={}) |
| | Generate UtcOffset values.
|
| Generator< TimeZone > | zones (const ZonesParams ¶ms={}) |
| | Generate TimeZone values.
|
| Generator< ZonedDateTime > | zoned_datetimes (const ZonedDatetimesParams ¶ms={}) |
| | Generate ZonedDateTime values: a zone, a wall-clock time in it and, when the clocks repeated that time, which repeat is meant.
|
| Generator< Span > | spans (SpansParams params={}) |
| | Generate Span values.
|
| template<typename TimePoint = Instant> |
| Generator< TimePoint > | instants (InstantsParams< TimePoint > params={}) |
| | Generate Instant values, or std::chrono::system_clock time points when TimePoint is one.
|
| template<typename Duration = SignedDuration> |
| Generator< Duration > | durations (DurationsParams< Duration > params={}) |
| | Generate SignedDuration values, or std::chrono::duration values when Duration is one.
|
| std::string | tzdb_version () |
| | The IANA release of the time zone database bundled in the engine, such as "2026e".
|
| std::optional< ZoneInfo > | info (std::string_view name) |
| | What the default zone source knows about name, matched exactly as the source spells it, or std::nullopt for a name it lacks.
|
| 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 instant of a repeated wall time (fold false); the later is the wall time read with offset_after.
|
| ZoneOffset | offset_at (std::string_view name, const Instant &instant) |
| | The offset the zone name has in force at instant.
|
| ZoneSource | default_zone_source () |
| | The process-wide default zone source: the one zones(), zoned_datetimes() and the info(), resolve() and offset_at() queries use when given no source.
|
| ZoneSource | set_default_zone_source (const ZoneSource &source) |
| | Replace the process-wide default zone source.
|
Date, Time, DateTime, Instant, UtcOffset, TimeZone, ZonedDateTime, SignedDuration and Span each compare for equality and have a total order, so they work as keys of std::set and std::map and in sets(); each also has a std::hash, for the unordered containers.
Date, Time, DateTime and Instant order from earlier to later and SignedDuration from shorter to longer. UtcOffset orders the unknown offset before every known one, then from west to east. TimeZone orders by name, then primary_name. ZonedDateTime orders by instant, then by its other fields. Span orders by its units, largest first, which is not an order by length: a span has no length without a date to start from.
|
| template<typename T> |
| constexpr detail::if_value< T, bool > | operator== (const T &a, const T &b) |
| template<typename T> |
| constexpr detail::if_value< T, bool > | operator!= (const T &a, const T &b) |
| template<typename T> |
| constexpr detail::if_value< T, bool > | operator< (const T &a, const T &b) |
| template<typename T> |
| constexpr detail::if_value< T, bool > | operator> (const T &a, const T &b) |
| template<typename T> |
| constexpr detail::if_value< T, bool > | operator<= (const T &a, const T &b) |
| template<typename T> |
| constexpr detail::if_value< T, bool > | operator>= (const T &a, const T &b) |
The text of a value is the text the engine defines for it. No value is refused: a value outside the range of its type prints its fields as they are.
|
| std::string | to_string (const Date &date) |
| std::string | to_string (const Time &time) |
| std::string | to_string (const DateTime &datetime) |
| std::string | to_string (const Instant &instant) |
| std::string | to_string (const UtcOffset &offset) |
| std::string | to_string (const TimeZone &zone) |
| std::string | to_string (const ZonedDateTime &zoned) |
| std::string | to_string (const SignedDuration &duration) |
| std::string | to_string (const Span &span) |
| template<typename T> |
| detail::if_value< T, std::ostream & > | operator<< (std::ostream &os, const T &value) |
| bool | operator== (const ZoneInfo &a, const ZoneInfo &b) |
| bool | operator!= (const ZoneInfo &a, const ZoneInfo &b) |
| bool | operator== (const ZoneOffset &a, const ZoneOffset &b) |
| bool | operator!= (const ZoneOffset &a, const ZoneOffset &b) |
|
|
constexpr int32_t | MIN_YEAR = -999'999 |
| | The lowest year of a Date.
|
|
constexpr int32_t | MAX_YEAR = 999'999 |
| | The highest year of a Date.
|
|
constexpr int64_t | MIN_INSTANT = -31'619'087'596'800 |
| | The first second of MIN_YEAR, the lowest second of an Instant.
|
|
constexpr int64_t | MAX_INSTANT = 31'494'784'780'799 |
| | The last second of MAX_YEAR, the highest second of an Instant.
|
|
constexpr int32_t | MAX_OFFSET = 93'599 |
| | The largest magnitude of a known UtcOffset in seconds, 25:59:59.
|
| constexpr std::string_view | UNKNOWN_ZONE = "Etc/Unknown" |
|
constexpr UtcOffset | UNKNOWN_OFFSET {0, false} |
| | The unknown offset, RFC 3339's -00:00.
|
| constexpr std::array< SpanUnit, 10 > | ALL_SPAN_UNITS |
| | Every SpanUnit, largest first.
|
| constexpr std::array< Tag, 16 > | ALL_TAGS |
| | Every Tag, in the order of the engine's bit set.
|
Date and time generators, and the plain values they draw.
Every value type here is an aggregate of public fields mirroring the engine's value model one to one, with no arithmetic and no parsing: a test that uses a date library wraps the value it draws with map, and nothing here competes with that library. The generators over these types are dates(), times(), datetimes(), instants(), offsets(), zones(), zoned_datetimes(), durations() and spans(), and the parameter structs and option enums they take. instants<TimePoint>() and durations<Duration>() draw std::chrono::system_clock time points and std::chrono durations.
Each value type compares, orders and hashes, and to_string() and operator<< give the text the engine defines for it, in the form of RFC 9557: 2024-03-10T01:30:00-05:00[America/New_York], with [gap] or [fold=0]/[fold=1] appended to a skipped or repeated wall time (2024-03-10T02:30:00-04:00[America/New_York][gap]), -00:00 for an unknown offset and Z[Etc/Unknown] for the unknown zone. A failure report shows a drawn value as its type and that text, such as hegel::generators::temporal::Date{"2024-03-10"}.
The functions resolve(), offset_at() and info() query the default zone source directly, outside any test: the engine's bundled IANA database unless set_default_zone_source() set another. A ZoneSource answers the same queries for its own data, and tzdb_version() names the bundled release.
Every zone draw resolves wall times against a zone source. C++ has no time zone database that every toolchain ships, so the default is the engine's bundled one. To draw against the database the code under test uses, build a ZoneSource from it (hegel/extras/boost_date_time.h does this for Boost.DateTime, and hegel/extras/chrono_tzdb.h for a standard library with std::chrono::tzdb) and pass it to zones() and zoned_datetimes(), or make it the default with set_default_zone_source(). A generator reads the default when it is built, and a query when it is called.
template<typename TimePoint = Instant>
Generate Instant values, or std::chrono::system_clock time points when TimePoint is one.
For Instant, the default: by default any instant of the engine's range, years ±999,999, at nanosecond precision; shrinks toward 2000-01-01T00:00:00Z or the nearest bound. One draw in twenty on average targets an interesting instant: the Unix epoch, the 32-bit and 64-bit boundaries, a leap second's or a time zone transition's.
For a std::chrono::time_point of std::chrono::system_clock, the same draw at the precision and within the range of the type, so that the type holds every drawn instant exactly. The precision is the finest of the engine's (Precision) that is a whole number of the duration's ticks: std::chrono::milliseconds draws whole milliseconds, and a tick of 100 nanoseconds whole microseconds. The default bounds are the widest both the type and the engine hold: a 64-bit count of nanoseconds gives the years 1678 to 2262, and one of seconds the engine's range. A failure report shows a drawn time point as its type and the text of the instant: std::chrono::sys_time<std::chrono::milliseconds>{"2024-03-10T02:30:00.5Z"}.
The duration must have an integer count of at most 64 bits and a tick that is a whole number of nanoseconds and divides a second, or a whole number of seconds that divides an hour. Any other duration, such as std::chrono::days or one finer than nanoseconds, does not compile: draw std::chrono::hours and convert. Only std::chrono::system_clock is supported, the one clock whose epoch every toolchain fixes at the Unix epoch; convert to another clock with std::chrono::clock_cast where the standard library has it.
auto at = tc.draw(
using sys_ms = std::chrono::sys_time<std::chrono::milliseconds>;
auto ms = tc.draw(gs::temporal::instants<sys_ms>(
{.min_value = sys_ms{std::chrono::milliseconds{0}}}));
auto now = tc.draw(
gs::temporal::instants<std::chrono::system_clock::time_point>());
- Template Parameters
-
| TimePoint | Instant (the default) or a std::chrono::time_point of std::chrono::system_clock. |
- Parameters
-
| params | Bounds and, for Instant, the precision. |
- Returns
- Generator producing instants.
- Exceptions
-
| std::invalid_argument | for an invalid or inverted bound, a bound outside the engine's range, or bounds holding no value at the precision. |
Generate ZonedDateTime values: a zone, a wall-clock time in it and, when the clocks repeated that time, which repeat is meant.
By default any zone zones() draws and any wall-clock time of the engine's range at nanosecond precision, with skipped wall times reported as TransitionKind::Gap and both repeats of a fold drawn; shrinks down the zone ladder, then toward 2000-01-01T00:00, preferring a unique wall time to a repeated one. One draw in twenty on average targets a transition of the zone, which is how gaps, folds and the exact boundary instants are reached. Build a native value from civil, the zone name and fold (or, for a gap, from instant), never from the offsets, so that a newer database on your side changes what a value means but never makes it invalid.
auto z = tc.draw(gs::temporal::zoned_datetimes(
{.zones = gs::temporal::zones({.names = {{"America/New_York"}}}),
.allow_imaginary = false}));
Any generator of zones works, such as one of your own zones. Its names are resolved against source, or against the default zone source when there is none, and a name that source does not know makes the draw throw std::invalid_argument:
auto local = tc.draw(gs::temporal::zoned_datetimes(
{.zones = gs::just(
TimeZone{
"Europe/Paris",
"Europe/Paris"})}));
auto mine = tc.draw(gs::temporal::zoned_datetimes(
{.zones = gs::temporal::zones({.source = my_source})
.filter([](const TimeZone& zone) {
return zone.name != "Etc/Skipped";
}),
.source = my_source}));
A time zone of a zone source, or UNKNOWN_ZONE.
Definition temporal_types.h:375
To draw every zone of a ZoneSource, pass it alone:
auto theirs =
tc.draw(gs::temporal::zoned_datetimes({.source = my_source}));
- Parameters
-
| params | Zones, their source, bounds and the gap and fold policies. |
- Returns
- Generator producing zoned datetimes.
- Exceptions
-
| std::invalid_argument | for both wall-clock and instant bounds, an invalid or inverted bound, bounds holding no value at the precision, or a source next to a zones generator that zones() returned. |