namespace std::chrono {
struct tzdb {
string version;
vector<time_zone> zones;
vector<link> links;
vector<leap> leaps;
const time_zone* locate_zone(string_view tz_name) const;
const time_zone* current_zone() const;
};
}const time_zone* locate_zone(string_view tz_name) const;
const time_zone* current_zone() const;
namespace std::chrono {
class tzdb_list {
public:
tzdb_list(const tzdb_list&) = delete;
tzdb_list& operator=(const tzdb_list&) = delete;
// unspecified additional constructors
class const_iterator;
const tzdb& front() const noexcept;
const_iterator erase_after(const_iterator p);
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
};
}const tzdb& front() const noexcept;
const_iterator erase_after(const_iterator p);
const_iterator begin() const noexcept;
const_iterator end() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
tzdb_list& get_tzdb_list();
const tzdb& get_tzdb();
const time_zone* locate_zone(string_view tz_name);
const time_zone* current_zone();
const tzdb& reload_tzdb();
string remote_version();
namespace std::chrono {
class nonexistent_local_time : public runtime_error {
public:
template<class Duration>
nonexistent_local_time(const local_time<Duration>& tp, const local_info& i);
};
}template<class Duration>
nonexistent_local_time(const local_time<Duration>& tp, const local_info& i);
ostringstream os;
os << tp << " is in a gap between\n"
<< local_seconds{i.first.end.time_since_epoch()} + i.first.offset << ' '
<< i.first.abbrev << " and\n"
<< local_seconds{i.second.begin.time_since_epoch()} + i.second.offset << ' '
<< i.second.abbrev
<< " which are both equivalent to\n"
<< i.first.end << " UTC";
#include <chrono>
#include <iostream>
int main() {
using namespace std::chrono;
try {
auto zt = zoned_time{"America/New_York",
local_days{Sunday[2]/March/2016} + 2h + 30min};
} catch (const nonexistent_local_time& e) {
std::cout << e.what() << '\n';
}
}2016-03-13 02:30:00 is in a gap between 2016-03-13 02:00:00 EST and 2016-03-13 03:00:00 EDT which are both equivalent to 2016-03-13 07:00:00 UTCββend example
namespace std::chrono {
class ambiguous_local_time : public runtime_error {
public:
template<class Duration>
ambiguous_local_time(const local_time<Duration>& tp, const local_info& i);
};
}template<class Duration>
ambiguous_local_time(const local_time<Duration>& tp, const local_info& i);
ostringstream os; os << tp << " is ambiguous. It could be\n" << tp << ' ' << i.first.abbrev << " == " << tp - i.first.offset << " UTC or\n" << tp << ' ' << i.second.abbrev << " == " << tp - i.second.offset << " UTC";
#include <chrono>
#include <iostream>
int main() {
using namespace std::chrono;
try {
auto zt = zoned_time{"America/New_York",
local_days{Sunday[1]/November/2016} + 1h + 30min};
} catch (const ambiguous_local_time& e) {
std::cout << e.what() << '\n';
}
}2016-11-06 01:30:00 is ambiguous. It could be 2016-11-06 01:30:00 EDT == 2016-11-06 05:30:00 UTC or 2016-11-06 01:30:00 EST == 2016-11-06 06:30:00 UTCββend example
namespace std::chrono {
struct sys_info {
sys_seconds begin;
sys_seconds end;
seconds offset;
minutes save;
string abbrev;
};
}offset = local_time - sys_time
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const sys_info& r);
namespace std::chrono {
struct local_info {
static constexpr int unique = 0;
static constexpr int nonexistent = 1;
static constexpr int ambiguous = 2;
int result;
sys_info first;
sys_info second;
};
}template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const local_info& r);
namespace std::chrono {
class time_zone {
public:
time_zone(time_zone&&) = default;
time_zone& operator=(time_zone&&) = default;
// unspecified additional constructors
string_view name() const noexcept;
template<class Duration> sys_info get_info(const sys_time<Duration>& st) const;
template<class Duration> local_info get_info(const local_time<Duration>& tp) const;
template<class Duration>
sys_time<common_type_t<Duration, seconds>>
to_sys(const local_time<Duration>& tp) const;
template<class Duration>
sys_time<common_type_t<Duration, seconds>>
to_sys(const local_time<Duration>& tp, choose z) const;
template<class Duration>
local_time<common_type_t<Duration, seconds>>
to_local(const sys_time<Duration>& tp) const;
};
}string_view name() const noexcept;
template<class Duration>
sys_info get_info(const sys_time<Duration>& st) const;
template<class Duration>
local_info get_info(const local_time<Duration>& tp) const;
template<class Duration>
sys_time<common_type_t<Duration, seconds>>
to_sys(const local_time<Duration>& tp) const;
template<class Duration>
sys_time<common_type_t<Duration, seconds>>
to_sys(const local_time<Duration>& tp, choose z) const;
template<class Duration>
local_time<common_type_t<Duration, seconds>>
to_local(const sys_time<Duration>& tp) const;
namespace std::chrono {
template<class T> struct zoned_traits {};
}
namespace std::chrono {
template<> struct zoned_traits<const time_zone*> {
static const time_zone* default_zone();
static const time_zone* locate_zone(string_view name);
};
} static const time_zone* default_zone();
static const time_zone* locate_zone(string_view name);
namespace std::chrono {
template<class Duration, class TimeZonePtr = const time_zone*>
class zoned_time {
public:
using duration = common_type_t<Duration, seconds>;
private:
TimeZonePtr zone_; // exposition only
sys_time<duration> tp_; // exposition only
using traits = zoned_traits<TimeZonePtr>; // exposition only
public:
zoned_time();
zoned_time(const zoned_time&) = default;
zoned_time& operator=(const zoned_time&) = default;
zoned_time(const sys_time<Duration>& st);
explicit zoned_time(TimeZonePtr z);
explicit zoned_time(string_view name);
template<class Duration2>
zoned_time(const zoned_time<Duration2, TimeZonePtr>& zt) noexcept;
zoned_time(TimeZonePtr z, const sys_time<Duration>& st);
zoned_time(string_view name, const sys_time<Duration>& st);
zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
zoned_time(string_view name, const local_time<Duration>& tp);
zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
zoned_time(string_view name, const local_time<Duration>& tp, choose c);
template<class Duration2, class TimeZonePtr2>
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt);
template<class Duration2, class TimeZonePtr2>
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt, choose);
zoned_time(string_view name, const zoned_time<Duration>& zt);
zoned_time(string_view name, const zoned_time<Duration>& zt, choose);
zoned_time& operator=(const sys_time<Duration>& st);
zoned_time& operator=(const local_time<Duration>& ut);
operator sys_time<duration>() const;
explicit operator local_time<duration>() const;
TimeZonePtr get_time_zone() const;
local_time<duration> get_local_time() const;
sys_time<duration> get_sys_time() const;
sys_info get_info() const;
};
zoned_time() -> zoned_time<seconds>;
template<class Duration>
zoned_time(sys_time<Duration>)
-> zoned_time<common_type_t<Duration, seconds>>;
template<class TimeZonePtr, class Duration>
zoned_time(TimeZonePtr, sys_time<Duration>)
-> zoned_time<common_type_t<Duration, seconds>, TimeZonePtr>;
template<class TimeZonePtr, class Duration>
zoned_time(TimeZonePtr, local_time<Duration>, choose = choose::earliest)
-> zoned_time<common_type_t<Duration, seconds>, TimeZonePtr>;
template<class TimeZonePtr, class Duration>
zoned_time(TimeZonePtr, zoned_time<Duration>, choose = choose::earliest)
-> zoned_time<common_type_t<Duration, seconds>, TimeZonePtr>;
zoned_time(string_view) -> zoned_time<seconds>;
template<class Duration>
zoned_time(string_view, sys_time<Duration>)
-> zoned_time<common_type_t<Duration, seconds>>;
template<class Duration>
zoned_time(string_view, local_time<Duration>, choose = choose::earliest)
-> zoned_time<common_type_t<Duration, seconds>>;
template<class Duration, class TimeZonePtr, class TimeZonePtr2>
zoned_time(TimeZonePtr, zoned_time<Duration, TimeZonePtr2>, choose = choose::earliest)
-> zoned_time<Duration, TimeZonePtr>;
}zoned_time();
zoned_time(const sys_time<Duration>& st);
explicit zoned_time(TimeZonePtr z);
explicit zoned_time(string_view name);
template<class Duration2>
zoned_time(const zoned_time<Duration2, TimeZonePtr>& y) noexcept;
zoned_time(TimeZonePtr z, const sys_time<Duration>& st);
zoned_time(string_view name, const sys_time<Duration>& st);
zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
zoned_time(string_view name, const local_time<Duration>& tp);
zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
zoned_time(string_view name, const local_time<Duration>& tp, choose c);
template<class Duration2, class TimeZonePtr2>
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y);
template<class Duration2, class TimeZonePtr2>
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y, choose);
zoned_time(string_view name, const zoned_time<Duration>& y);
zoned_time(string_view name, const zoned_time<Duration>& y, choose c);
zoned_time& operator=(const sys_time<Duration>& st);
zoned_time& operator=(const local_time<Duration>& lt);
operator sys_time<duration>() const;
explicit operator local_time<duration>() const;
TimeZonePtr get_time_zone() const;
local_time<duration> get_local_time() const;
sys_time<duration> get_sys_time() const;
sys_info get_info() const;
template<class Duration1, class Duration2, class TimeZonePtr>
bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
const zoned_time<Duration2, TimeZonePtr>& y);
template<class Duration1, class Duration2, class TimeZonePtr>
bool operator!=(const zoned_time<Duration1, TimeZonePtr>& x,
const zoned_time<Duration2, TimeZonePtr>& y);
template<class charT, class traits, class Duration, class TimeZonePtr>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os,
const zoned_time<Duration, TimeZonePtr>& t);
template<class charT, class traits, class Duration, class TimeZonePtr>
basic_ostream<charT, traits>&
to_stream(basic_ostream<charT, traits>& os, const charT* fmt,
const zoned_time<Duration, TimeZonePtr>& tp);
namespace std::chrono {
class leap {
public:
leap(const leap&) = default;
leap& operator=(const leap&) = default;
// unspecified additional constructors
constexpr sys_seconds date() const noexcept;
};
}
for (auto& l : get_tzdb().leaps)
if (l <= 2018y/March/17d)
cout << l.date() << '\n';1972-07-01 00:00:00 1973-01-01 00:00:00 1974-01-01 00:00:00 1975-01-01 00:00:00 1976-01-01 00:00:00 1977-01-01 00:00:00 1978-01-01 00:00:00 1979-01-01 00:00:00 1980-01-01 00:00:00 1981-07-01 00:00:00 1982-07-01 00:00:00 1983-07-01 00:00:00 1985-07-01 00:00:00 1988-01-01 00:00:00 1990-01-01 00:00:00 1991-01-01 00:00:00 1992-07-01 00:00:00 1993-07-01 00:00:00 1994-07-01 00:00:00 1996-01-01 00:00:00 1997-07-01 00:00:00 1999-01-01 00:00:00 2006-01-01 00:00:00 2009-01-01 00:00:00 2012-07-01 00:00:00 2015-07-01 00:00:00 2017-01-01 00:00:00ββend example
constexpr bool operator==(const leap& x, const leap& y) noexcept;
constexpr bool operator<(const leap& x, const leap& y) noexcept;
template<class Duration>
constexpr bool operator==(const leap& x, const sys_time<Duration>& y) noexcept;
template<class Duration>
constexpr bool operator==(const sys_time<Duration>& x, const leap& y) noexcept;
template<class Duration>
constexpr bool operator!=(const leap& x, const sys_time<Duration>& y) noexcept;
template<class Duration>
constexpr bool operator!=(const sys_time<Duration>& x, const leap& y) noexcept;
template<class Duration>
constexpr bool operator<(const leap& x, const sys_time<Duration>& y) noexcept;
template<class Duration>
constexpr bool operator<(const sys_time<Duration>& x, const leap& y) noexcept;
template<class Duration>
constexpr bool operator>(const leap& x, const sys_time<Duration>& y) noexcept;
template<class Duration>
constexpr bool operator>(const sys_time<Duration>& x, const leap& y) noexcept;
template<class Duration>
constexpr bool operator<=(const leap& x, const sys_time<Duration>& y) noexcept;
template<class Duration>
constexpr bool operator<=(const sys_time<Duration>& x, const leap& y) noexcept;
template<class Duration>
constexpr bool operator>=(const leap& x, const sys_time<Duration>& y) noexcept;
template<class Duration>
constexpr bool operator>=(const sys_time<Duration>& x, const leap& y) noexcept;
namespace std::chrono {
class link {
public:
link(link&&) = default;
link& operator=(link&&) = default;
// unspecified additional constructors
string_view name() const noexcept;
string_view target() const noexcept;
};
}string_view name() const noexcept;
string_view target() const noexcept;