forked from HowardHinnant/date
Document clock_cast for local_time.
Document clock_time_conversion<D, local_t> calling D::from_local and clock_time_conversion<locat_t, S> calling S::to_local. To avoid ambiguities addes: * clock_time_conversion<local_t, local_t> - idenitity * clock_time_conversion<local_t, utc_clock> - same as default (utc_clock::to_local) * clock_time_conversion<utc_clock, local_t> - same as default (utc_clock::from_local) In addition, as std::chrono::system_clock cannot be edited, added: * clock_time_conversion<local_t, std::chrono::system_clock> - assumes same epoch * clock_time_conversion<std::chrono::system_clock, local_t> - assumes same epoch
This commit is contained in:
268
tz.html
268
tz.html
@@ -26,7 +26,7 @@
|
||||
<br/>
|
||||
<br/>
|
||||
<a href="mailto:howard.hinnant@gmail.com">Howard E. Hinnant</a><br/>
|
||||
2018-06-02<br/>
|
||||
2018-06-11<br/>
|
||||
</address>
|
||||
<hr/>
|
||||
<h1 align=center>Time Zone Database Parser</h1>
|
||||
@@ -2690,6 +2690,16 @@ public:
|
||||
static
|
||||
utc_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
from_sys(const sys_time<Duration>&);
|
||||
|
||||
template <class Duration>
|
||||
static
|
||||
local_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
to_local(const utc_time<Duration>&);
|
||||
|
||||
template <class Duration>
|
||||
static
|
||||
utc_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
from_local(const local_time<Duration>&);
|
||||
};
|
||||
|
||||
template <class Duration>
|
||||
@@ -2756,6 +2766,30 @@ second insertion), then the conversion counts that leap second as inserted.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <class Duration>
|
||||
static
|
||||
local_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
utc_clock::to_local(const utc_time<Duration>& u);
|
||||
</pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>local_time<Duration>{to_sys(u).time_since_epoch()}</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <class Duration>
|
||||
static
|
||||
utc_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
utc_clock::from_local(const local_time<Duration>& t);
|
||||
</pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>from_sys(sys_time<Duration>{t.time_since_epoch()})</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_ostream<class CharT, class Traits>&
|
||||
@@ -2896,6 +2930,16 @@ public:
|
||||
static
|
||||
tai_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
from_utc(const utc_time<Duration>&) noexcept;
|
||||
|
||||
template <class Duration>
|
||||
static
|
||||
local_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
to_local(const tai_time<Duration>&) noexcept;
|
||||
|
||||
template <class Duration>
|
||||
static
|
||||
tai_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
from_local(const local_time<Duration>&) noexcept;
|
||||
};
|
||||
|
||||
template <class Duration>
|
||||
@@ -2958,6 +3002,32 @@ tai_clock::from_utc(const utc_time<Duration>& t) noexcept;
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <class Duration>
|
||||
static
|
||||
local_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
tai_clock::to_local(const tai_time<Duration>& t) noexcept;
|
||||
</pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>local_time<Duration>{t.time_since_epoch()} -
|
||||
(local_days{1970_y/January/1} - local_days{1958_y/January/1})</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <class Duration>
|
||||
static
|
||||
tai_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
tai_clock::from_local(const local_time<Duration>& t) noexcept;
|
||||
</pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>tai_time<Duration>{t.time_since_epoch()} +
|
||||
(local_days{1970_y/January/1} - local_days{1958_y/January/1})</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_ostream<class CharT, class Traits>&
|
||||
@@ -3041,6 +3111,16 @@ public:
|
||||
static
|
||||
gps_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
from_utc(const utc_time<Duration>&) noexcept;
|
||||
|
||||
template <class Duration>
|
||||
static
|
||||
local_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
to_local(const gps_time<Duration>&) noexcept;
|
||||
|
||||
template <class Duration>
|
||||
static
|
||||
gps_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
from_local(const local_time<Duration>&) noexcept;
|
||||
};
|
||||
|
||||
template <class Duration>
|
||||
@@ -3102,6 +3182,32 @@ gps_clock::from_utc(const utc_time<Duration>& t) noexcept;
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <class Duration>
|
||||
static
|
||||
local_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
gps_clock::to_local(const gps_time<Duration>& t) noexcept;
|
||||
</pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>local_time<Duration>{t.time_since_epoch()} +
|
||||
(local_days{1980_y/January/Sunday[1]} - local_days{1970_y/January/1})</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <class Duration>
|
||||
static
|
||||
gps_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
gps_clock::from_local(const local_time<Duration>& t) noexcept;
|
||||
</pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>local_time<Duration>{t.time_since_epoch()} -
|
||||
(local_days{1980_y/January/Sunday[1]} - local_days{1970_y/January/1})</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_ostream<class CharT, class Traits>&
|
||||
@@ -3312,6 +3418,26 @@ operator()(const utc_time<Duration>& t) const;
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <>
|
||||
struct clock_time_conversion<local_t, local_t>
|
||||
{
|
||||
template <class Duration>
|
||||
local_time<Duration>
|
||||
operator()(const local_time<Duration>& t) const;
|
||||
};
|
||||
|
||||
template <class Duration>
|
||||
local_time<Duration>
|
||||
operator()(const local_time<Duration>& t) const;
|
||||
</pre>
|
||||
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>t</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
// system_clock <-> utc_clock
|
||||
</pre>
|
||||
@@ -3356,6 +3482,94 @@ operator()(const utc_time<Duration>& t) const;
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
// system_clock <-> local_t
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
template <>
|
||||
struct clock_time_conversion<local_t, std::chrono::system_clock>
|
||||
{
|
||||
template <class Duration>
|
||||
local_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
operator()(const sys_time<Duration>& t) const;
|
||||
};
|
||||
|
||||
template <class Duration>
|
||||
local_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
operator()(const sys_time<Duration>& t) const;
|
||||
</pre>
|
||||
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>local_time<Duration>{t.time_since_epoch()}</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <>
|
||||
struct clock_time_conversion<std::chrono::system_clock, local_t>
|
||||
{
|
||||
template <class Duration>
|
||||
sys_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
operator()(const local_t<Duration>& t) const;
|
||||
};
|
||||
|
||||
template <class Duration>
|
||||
sys_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
operator()(const local_t<Duration>& t) const;
|
||||
</pre>
|
||||
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>sys_time<Duration>{t.time_since_epoch()}</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
// utc_clock <-> local_t
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
template <>
|
||||
struct clock_time_conversion<local_t, utc_clock>
|
||||
{
|
||||
template <class Duration>
|
||||
local_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
operator()(const utc_time<Duration>& t) const;
|
||||
};
|
||||
|
||||
template <class Duration>
|
||||
local_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
operator()(const utc_time<Duration>& t) const;
|
||||
</pre>
|
||||
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>utc_clock::to_local(t)</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <>
|
||||
struct clock_time_conversion<utc_clock, local_t>
|
||||
{
|
||||
template <class Duration>
|
||||
utc_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
operator()(const local_t<Duration>& t) const;
|
||||
};
|
||||
|
||||
template <class Duration>
|
||||
utc_time<std::common_type_t<Duration, std::chrono::seconds>>
|
||||
operator()(const local_t<Duration>& t) const;
|
||||
</pre>
|
||||
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>utc_clock::from_local(t)</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
// Clock <-> system_clock
|
||||
</pre>
|
||||
@@ -3477,6 +3691,58 @@ operator()(const utc_time<Duration>& t) const
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
// Clock <-> local_t
|
||||
</pre>
|
||||
|
||||
<pre>
|
||||
template <class SourceClock>
|
||||
struct clock_time_conversion<local_t, SourceClock>
|
||||
{
|
||||
template <class Duration>
|
||||
auto
|
||||
operator()(const std::chrono::time_point<SourceClock, Duration>& t) const
|
||||
-> decltype(SourceClock::to_local(t));
|
||||
};
|
||||
|
||||
template <class Duration>
|
||||
auto
|
||||
operator()(const std::chrono::time_point<SourceClock, Duration>& t) const
|
||||
-> decltype(SourceClock::to_local(t));
|
||||
</pre>
|
||||
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Remarks:</i> This function does not participate in overload resolution unless
|
||||
<code>SourceClock::to_local(t)</code> is well formed. If
|
||||
<code>SourceClock::to_local(t)</code> does not return
|
||||
<code>local_time<<i>some duration</i>></code> the program is ill-formed.
|
||||
</p>
|
||||
<p>
|
||||
<i>Returns:</i> <code>SourceClock::to_local(t)</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
template <class Duration>
|
||||
auto
|
||||
operator()(const local_time<Duration>& t) const
|
||||
-> decltype(DestClock::from_local(t));
|
||||
</pre>
|
||||
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Remarks:</i> This function does not participate in overload resolution unless
|
||||
<code>DestClock::from_local(t)</code> is well formed. If
|
||||
<code>DestClock::from_local(t)</code> does not return
|
||||
<code>time_point<DestClock, <i>some duration</i>></code> the program is ill-formed.
|
||||
<code></code>.
|
||||
</p>
|
||||
<p>
|
||||
<i>Returns:</i> <code>DestClock::from_local(t)</code>.
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>
|
||||
// clock_cast
|
||||
</pre>
|
||||
|
Reference in New Issue
Block a user