Country Generator 3.3.2
Procedural country generation for C++23
Loading...
Searching...
No Matches
dasmig::time_zone Class Reference

An IANA time zone of a country, with its rules. More...

#include <countrygen.hpp>

Public Member Functions

std::chrono::local_seconds to_local (std::chrono::sys_seconds t) const
 Local time at a UTC instant.
 
std::chrono::sys_seconds to_utc (std::chrono::local_seconds t, core::tz_choose choose=core::tz_choose::earliest) const
 The UTC instant of a local time.
 
std::uint64_t seed () const
 The seed this zone was drawn with.
 
const core::seed_signature & signature () const
 The seed and the data this zone was drawn from.
 
void to_json (core::json_writer &w) const
 Write this zone as a JSON object; the offset as ±HH:MM.
 
std::string to_json () const
 This zone as a JSON document.
 
 operator std::string () const
 Implicit conversion to std::string.
 

Public Attributes

std::string name
 IANA name: "America/Sao_Paulo".
 
std::string country_code
 ISO 3166-1 alpha-2: "BR".
 
double share {0.0}
 Percent of the country's population in the zone (GeoNames).
 
std::string basis
 "tzdata", "geonames" or "fallback" (doc/data.md).
 
core::tz_rules rules
 The zone's rules, from the tier's first year on.
 
std::chrono::seconds utc_offset {}
 At the reference date, 12:00 UTC: east of UTC.
 
std::string abbreviation
 At the reference date: "-03", "CEST".
 
bool dst {false}
 At the reference date: daylight time.
 
bool observes_dst {false}
 Any daylight time from the reference date on.
 

Friends

class cntg
 
std::ostream & operator<< (std::ostream &os, const time_zone &z)
 Stream the IANA name.
 

Detailed Description

An IANA time zone of a country, with its rules.

Definition at line 1573 of file countrygen.hpp.

Member Function Documentation

◆ operator std::string()

dasmig::time_zone::operator std::string ( ) const
inline

Implicit conversion to std::string.

Returns
The IANA name.

Definition at line 1651 of file countrygen.hpp.

◆ seed()

std::uint64_t dasmig::time_zone::seed ( ) const
inline

The seed this zone was drawn with.

Returns
The per-call seed (0 for find_time_zone() and time_zones()).

Definition at line 1606 of file countrygen.hpp.

◆ signature()

const core::seed_signature & dasmig::time_zone::signature ( ) const
inline

The seed and the data this zone was drawn from.

Returns
The replay signature.

Definition at line 1610 of file countrygen.hpp.

◆ to_json() [1/2]

std::string dasmig::time_zone::to_json ( ) const
inline

This zone as a JSON document.

Returns
Compact JSON.

Definition at line 1642 of file countrygen.hpp.

◆ to_json() [2/2]

void dasmig::time_zone::to_json ( core::json_writer &  w) const
inline

Write this zone as a JSON object; the offset as ±HH:MM.

Parameters
wWriter positioned where a value is allowed.

Definition at line 1614 of file countrygen.hpp.

◆ to_local()

std::chrono::local_seconds dasmig::time_zone::to_local ( std::chrono::sys_seconds  t) const
inline

Local time at a UTC instant.

Parameters
tThe instant.
Returns
The local time.
Exceptions
std::out_of_rangeBefore the zone's data (core::tz_rules).

Definition at line 1591 of file countrygen.hpp.

◆ to_utc()

std::chrono::sys_seconds dasmig::time_zone::to_utc ( std::chrono::local_seconds  t,
core::tz_choose  choose = core::tz_choose::earliest 
) const
inline

The UTC instant of a local time.

Parameters
tThe local time.
chooseWhich instant, for a local time that occurs twice.
Returns
The instant (a local time in a gap is moved forward by the gap).
Exceptions
std::out_of_rangeBefore the zone's data (core::tz_rules).

Definition at line 1598 of file countrygen.hpp.

Friends And Related Symbol Documentation

◆ cntg

friend class cntg
friend

Definition at line 1668 of file countrygen.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const time_zone &  z 
)
friend

Stream the IANA name.

Parameters
osOutput stream.
zZone to stream.
Returns
The stream.

Definition at line 1660 of file countrygen.hpp.

Member Data Documentation

◆ abbreviation

std::string dasmig::time_zone::abbreviation

At the reference date: "-03", "CEST".

Definition at line 1583 of file countrygen.hpp.

◆ basis

std::string dasmig::time_zone::basis

"tzdata", "geonames" or "fallback" (doc/data.md).

Definition at line 1579 of file countrygen.hpp.

◆ country_code

std::string dasmig::time_zone::country_code

ISO 3166-1 alpha-2: "BR".

Definition at line 1577 of file countrygen.hpp.

◆ dst

bool dasmig::time_zone::dst {false}

At the reference date: daylight time.

Definition at line 1584 of file countrygen.hpp.

◆ name

std::string dasmig::time_zone::name

IANA name: "America/Sao_Paulo".

Definition at line 1576 of file countrygen.hpp.

◆ observes_dst

bool dasmig::time_zone::observes_dst {false}

Any daylight time from the reference date on.

Definition at line 1585 of file countrygen.hpp.

◆ rules

core::tz_rules dasmig::time_zone::rules

The zone's rules, from the tier's first year on.

Definition at line 1580 of file countrygen.hpp.

◆ share

double dasmig::time_zone::share {0.0}

Percent of the country's population in the zone (GeoNames).

Definition at line 1578 of file countrygen.hpp.

◆ utc_offset

std::chrono::seconds dasmig::time_zone::utc_offset {}

At the reference date, 12:00 UTC: east of UTC.

Definition at line 1582 of file countrygen.hpp.


The documentation for this class was generated from the following file: