From 026caba1c4776ce731a141eae33358a6d84138da Mon Sep 17 00:00:00 2001
From: Howard Hinnant
-Returns:
+Returns: A
@@ -2397,85 +2401,28 @@ second insertion), then the conversion counts that leap second as inserted.
-Returns: A
-Returns:
-Returns:
-[Example:
-
-Output:
-
-— end example]
-
-Returns: A
-Returns: A
-Returns:
-Returns:
+Equivalent to:
-Returns: A
-Returns: A
-Returns:
-Returns:
+Equivalent to:
Howard E. Hinnant
-2016-09-14
+2016-10-08
Time Zone Database Parser
@@ -2342,16 +2342,6 @@ public:
static constexpr bool is_steady = true;
static time_point now() noexcept;
-
- template <class Duration>
- static
- utc_time<std::common_type_t<Duration, std::chrono::seconds>>
- sys_to_utc(sys_time<Duration> t);
-
- template <class Duration>
- static
- sys_time<std::common_type_t<Duration, std::chrono::seconds>>
- utc_to_sys(utc_time<Duration> u);
};
template <class Duration>
@@ -2375,15 +2365,29 @@ static utc_clock::time_point utc_clock::now() noexcept;
+
+sys_to_utc(system_clock::now())
.
+Returns: to_utc_time(system_clock::now())
.
+
+template <class Duration>
+sys_time<std::common_type_t<Duration, std::chrono::seconds>>
+to_sys_time(utc_time<Duration> u)
+
+
+
sys_time
t
, such that
+to_utc_time(t) == u
if such a mapping exists. Otherwise u
+represents a time_point
during a leap second insertion and the last
+representable value of sys_time
prior to the insertion of the leap
+second is returned.
template <class Duration>
-static
utc_time<std::common_type_t<Duration, std::chrono::seconds>>
-utc_clock::sys_to_utc(sys_time<Duration> t);
+to_utc_time(sys_time<Duration> t)
template <class Duration>
-static
-sys_time<std::common_type_t<Duration, std::chrono::seconds>>
-utc_clock::utc_to_sys(utc_time<Duration> u);
+utc_time<std::common_type_t<Duration, std::chrono::seconds>>
+to_utc_time(tai_time<Duration> t)
sys_time
t
, such that
-utc_clock::sys_to_utc(t) == u
.
+Returns: A utc_time
u
, such that
+to_tai_time(u) == t
.
template <class Duration>
utc_time<std::common_type_t<Duration, std::chrono::seconds>>
-to_utc_time(sys_time<Duration> t)
+to_utc_time(gps_time<Duration> t)
-utc_clock::sys_to_utc(t)
.
+Returns: A utc_time
u
, such that
+to_gps_time(u) == t
.
-template <class Duration>
-sys_time<std::common_type_t<Duration, std::chrono::seconds>>
-to_sys_time(utc_time<Duration> u)
-
-
-
-
-utc_clock::utc_to_sys(u)
.
-
-
-
-#include "tz.h"
-#include <iostream>
-
-int
-main()
-{
- using namespace date;
- using namespace std::chrono_literals;
- auto t0 = sys_days{1972_y/jul/1} - 1ms;
- auto u0 = to_utc_time(t0);
- auto t1 = to_sys_time(u0);
- std::cout << t0 << ":\n";
- std::cout << (u0.time_since_epoch() - t0.time_since_epoch()).count() << "ms\n";
- std::cout << (t1 - t0).count() << "ms\n\n";
-
- t0 += 1ms;
- u0 = to_utc_time(t0);
- t1 = to_sys_time(u0);
- std::cout << t0 << ":\n";
- std::cout << (u0.time_since_epoch() - t0.time_since_epoch()).count() << "ms\n";
- std::cout << (t1 - t0).count() << "ms\n";
-}
-
-
-1972-06-30 23:59:59.999:
-0ms
-0ms
-
-1972-07-01 00:00:00.000:
-1000ms
-0ms
-
-
template <class CharT, class Traits, class Duration>
std::basic_ostream<class CharT, class Traits>&
@@ -2507,16 +2454,6 @@ public:
static constexpr bool is_steady = true;
static time_point now() noexcept;
-
- template <class Duration>
- static
- tai_time<std::common_type_t<Duration, std::chrono::seconds>>
- utc_to_tai(utc_time<Duration> t);
-
- template <class Duration>
- static
- utc_time<std::common_type_t<Duration, std::chrono::seconds>>
- tai_to_utc(tai_time<Duration> u);
};
template <class Duration>
@@ -2544,38 +2481,23 @@ static tai_clock::time_point tai_clock::now() noexcept;
template <class Duration>
-static
-tai_time<std::common_type_t<Duration, std::chrono::seconds>>
-tai_clock::utc_to_tai(utc_time<Duration> t);
+sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
+to_sys_time(tai_time<Duration> t)
tai_time
which represents time as measured by
-TAI at the same instant as the time t
in UTC.
+Equivalent to: return to_sys_time(to_utc_time(t))
.
template <class Duration>
-static
-utc_time<std::common_type_t<Duration, std::chrono::seconds>>
-tai_clock::tai_to_utc(tai_time<Duration> t);
+tai_time<typename std::common_type<Duration, std::chrono::seconds>::type>
+to_tai_time(sys_time<Duration> t)
-
-utc_time
u
, such that
-tai_clock::utc_to_tai(u) == t
.
-
-template <class Duration>
-utc_time<std::common_type_t<Duration, std::chrono::seconds>>
-to_utc_time(tai_time<Duration> t)
-
-
-
@@ -2586,7 +2508,19 @@ to_tai_time(utc_time<Duration> u)
tai_clock::tai_to_utc(t)
.
+Equivalent to: return to_tai_time(to_utc_time(t))
.
+
+tai_clock::utc_to_tai(u)
.
+Returns: A tai_time
which represents time as measured by
+TAI at the same instant as the time t
in UTC.
+
+template <class Duration>
+tai_time<typename std::common_type<Duration, std::chrono::seconds>::type>
+to_tai_time(gps_time<Duration> t)
+
+
+
@@ -2619,16 +2553,6 @@ public:
static constexpr bool is_steady = true;
static time_point now() noexcept;
-
- template <class Duration>
- static
- gps_time<std::common_type_t<Duration, std::chrono::seconds>>
- utc_to_gps(utc_time<Duration> t);
-
- template <class Duration>
- static
- utc_time<std::common_type_t<Duration, std::chrono::seconds>>
- gps_to_utc(gps_time<Duration> u);
};
template <class Duration>
@@ -2655,38 +2579,23 @@ static gps_clock::time_point gps_clock::now() noexcept;
return to_tai_time(to_utc_time(t))
.
template <class Duration>
-static
-gps_time<std::common_type_t<Duration, std::chrono::seconds>>
-gps_clock::utc_to_gps(utc_time<Duration> t);
+sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
+to_sys_time(gps_time<Duration> t)
gps_time
which represents time as measured by
-GPS at the same instant as the time t
in UTC.
+Equivalent to: return to_sys_time(to_utc_time(t))
.
template <class Duration>
-static
-utc_time<std::common_type_t<Duration, std::chrono::seconds>>
-gps_clock::gps_to_utc(gps_time<Duration> t);
+gps_time<typename std::common_type<Duration, std::chrono::seconds>::type>
+to_gps_time(sys_time<Duration> t)
-
-utc_time
u
, such that
-gps_clock::utc_to_gps(u) == t
.
-
-template <class Duration>
-utc_time<std::common_type_t<Duration, std::chrono::seconds>>
-to_utc_time(gps_time<Duration> t)
-
-
-
@@ -2697,7 +2606,19 @@ to_gps_time(utc_time<Duration> u)
gps_clock::gps_to_utc(t)
.
+Equivalent to: return to_gps_time(to_utc_time(t))
.
+
+gps_clock::utc_to_gps(u)
.
+Returns: A gps_time
which represents time as measured by
+GPS at the same instant as the time t
in UTC.
+
+template <class Duration>
+gps_time<typename std::common_type<Duration, std::chrono::seconds>::type>
+to_gps_time(tai_time<Duration> t)
+
+
+
@@ -2715,74 +2636,6 @@ operator<<(std::basic_ostream<class CharT, class Traits>& os, co
return to_gps_time(to_utc_time(t))
.
Convenience converters
- --template <class Duration> -sys_time<typename std::common_type<Duration, std::chrono::seconds>::type> -to_sys_time(tai_time<Duration> t) --
-- --Returns:
-to_sys_time(to_utc_time(t))
. -
-template <class Duration> -sys_time<typename std::common_type<Duration, std::chrono::seconds>::type> -to_sys_time(gps_time<Duration> t) --
-- --Returns:
-to_sys_time(to_utc_time(t))
. -
-template <class Duration> -tai_time<typename std::common_type<Duration, std::chrono::seconds>::type> -to_tai_time(sys_time<Duration> t) --
-- --Returns:
-to_tai_time(to_utc_time(t))
. -
-template <class Duration> -tai_time<typename std::common_type<Duration, std::chrono::seconds>::type> -to_tai_time(gps_time<Duration> t) --
-- --Returns:
-to_tai_time(to_utc_time(t))
. -
-template <class Duration> -gps_time<typename std::common_type<Duration, std::chrono::seconds>::type> -to_gps_time(sys_time<Duration> t) --
-- --Returns:
-to_gps_time(to_utc_time(t))
. -
-template <class Duration> -gps_time<typename std::common_type<Duration, std::chrono::seconds>::type> -to_gps_time(tai_time<Duration> t) --
---Returns:
-to_gps_time(to_utc_time(t))
. -
[Example: