Rewrite format and parse in terms of detail::fields<Duration>

* Add format and parse to utc_time<Duration>.
* Added more tests.
This commit is contained in:
Howard Hinnant 2017-02-25 20:45:16 -05:00
parent fa86a381d1
commit 4f89141e56
2 changed files with 142 additions and 7 deletions

View File

@ -6326,6 +6326,7 @@ time_of_day&lt;std::chrono::hours&gt;
public:
using precision = std::chrono::hours;
constexpr time_of_day() noexcept;
constexpr explicit time_of_day(std::chrono::hours since_midnight) noexcept;
constexpr std::chrono::hours hours() const noexcept;
@ -6339,6 +6340,21 @@ public:
};
</pre>
<pre>
constexpr time_of_day&lt;std::chrono::hours&gt;::time_of_day() noexcept;
</pre>
<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>time_of_day</code> in 24-hour format
corresponding to 00:00:00 hours after 00:00:00.
</p>
<p>
<i>Postconditions:</i> <code>hours()</code> returns <code>0h</code>.
<code>mode()</code> returns <code>0</code>.
</p>
</blockquote>
<pre>
constexpr explicit time_of_day&lt;std::chrono::hours&gt;::time_of_day(std::chrono::hours since_midnight) noexcept;
</pre>
@ -6453,6 +6469,7 @@ time_of_day&lt;std::chrono::minutes&gt;
public:
using precision = std::chrono::minutes;
constexpr time_of_day() noexcept;
constexpr explicit time_of_day(std::chrono::minutes since_midnight) noexcept;
constexpr std::chrono::hours hours() const noexcept;
@ -6467,6 +6484,21 @@ public:
};
</pre>
<pre>
constexpr time_of_day&lt;std::chrono::minutes&gt;::time_of_day() noexcept;
</pre>
<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>time_of_day</code> in 24-hour format
corresponding to 0 minutes after 00:00:00.
</p>
<p>
<i>Postconditions:</i> <code>hours()</code> returns <code>0h</code>.
<code>minutes()</code> returns <code>0min</code>. <code>mode()</code> returns <code>0</code>.
</p>
</blockquote>
<pre>
constexpr explicit time_of_day&lt;std::chrono::minutes&gt;::time_of_day(std::chrono::minutes since_midnight) noexcept;
</pre>
@ -6593,6 +6625,7 @@ time_of_day&lt;std::chrono::seconds&gt;
public:
using precision = std::chrono::seconds;
constexpr time_of_day() noexcept;
constexpr explicit time_of_day(std::chrono::seconds since_midnight) noexcept;
constexpr std::chrono::hours hours() const noexcept;
@ -6608,6 +6641,22 @@ public:
};
</pre>
<pre>
constexpr time_of_day&lt;std::chrono::seconds&gt;::time_of_day() noexcept;
</pre>
<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>time_of_day</code> in 24-hour format
corresponding to 0 seconds after 00:00:00.
</p>
<p>
<i>Postconditions:</i> <code>hours()</code> returns <code>0h</code>.
<code>minutes()</code> returns <code>0min</code>. <code>seconds()</code> returns
<code>0s</code>. <code>mode()</code> returns <code>0</code>.
</p>
</blockquote>
<pre>
constexpr explicit time_of_day&lt;std::chrono::seconds&gt;::time_of_day(std::chrono::seconds since_midnight) noexcept;
</pre>
@ -6746,6 +6795,7 @@ time_of_day&lt;std::chrono::duration&lt;Rep, Period&gt;&gt;
public:
using precision = <i>The decimal-based duration used to format</i>
constexpr time_of_day() noexcept;
constexpr explicit time_of_day(std::chrono::duration&lt;Rep, Period&gt; since_midnight) noexcept;
constexpr std::chrono::hours hours() const noexcept;
@ -6766,6 +6816,25 @@ public:
This specialization shall not exist unless <code>Period &lt; 1s</code>.
</p>
<pre>
constexpr
time_of_day&lt;std::chrono::duration&lt;Rep, Period&gt;&gt;::time_of_day() noexcept;
</pre>
<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>time_of_day</code> in 24-hour format
corresponding to 0 fractional seconds after 00:00:00.
</p>
<p>
<i>Postconditions:</i> <code>hours()</code> returns <code>0h</code>.
<code>minutes()</code> returns <code>0min</code>.
<code>seconds()</code> returns <code>0s</code>.
<code>subseconds()</code> returns 0 fractional precision seconds.
<code>mode()</code> returns <code>0</code>.
</p>
</blockquote>
<pre>
constexpr explicit
time_of_day&lt;std::chrono::duration&lt;Rep, Period&gt;&gt;::time_of_day(std::chrono::duration&lt;Rep, Period&gt; since_midnight) noexcept;

80
tz.html
View File

@ -26,7 +26,7 @@
<br/>
<br/>
<a href="mailto:howard.hinnant@gmail.com">Howard E. Hinnant</a><br/>
2017-01-28<br/>
2017-02-25<br/>
</address>
<hr/>
<h1 align=center>Time Zone Database Parser</h1>
@ -2001,8 +2001,6 @@ void
to_stream(std::basic_ostream&lt;CharT, Traits&gt;&amp; os, const CharT* fmt,
const std::chrono::duration&lt;Rep, Period&gt;& d);
</pre>
<blockquote>
</blockquote>
<pre>
template &lt;class CharT, class Traits, class Duration&gt;
@ -2010,8 +2008,6 @@ void
to_stream(std::basic_ostream&lt;CharT, Traits&gt;&amp; os, const CharT* fmt,
const local_time&lt;Duration&gt;&amp; tp);
</pre>
<blockquote>
</blockquote>
<pre>
template &lt;class CharT, class Traits, class Duration&gt;
@ -2019,8 +2015,6 @@ void
to_stream(std::basic_ostream&lt;CharT, Traits&gt;&amp; os, const CharT* fmt,
const sys_time&lt;Duration&gt;&amp; tp);
</pre>
<blockquote>
</blockquote>
<pre>
template &lt;class CharT, class Traits, class Duration&gt;
@ -2028,6 +2022,14 @@ void
to_stream(std::basic_ostream&lt;CharT, Traits&gt;&amp; os, const CharT* fmt,
const zoned_time&lt;Duration&gt;&amp; tp);
</pre>
<pre>
template &lt;class CharT, class Traits, class Duration&gt;
void
to_stream(std::basic_ostream&lt;CharT, Traits&gt;&amp; os, const CharT* fmt,
const utc_time&lt;Duration&gt;&amp; tp);
</pre>
<blockquote>
<p>
These are lower-level functions with respect to <code>format</code>. These functions
@ -2071,6 +2073,15 @@ template &lt;class CharT, class Traits, class Duration&gt;
std::basic_string&lt;class CharT, class Traits&gt;
format(const std::basic_string&lt;class CharT, class Traits&gt;&amp; format, const sys_time&lt;Duration&gt;&amp; tp);
template &lt;class CharT, class Traits, class Duration&gt;
std::basic_string&lt;class CharT, class Traits&gt;
format(const std::locale&amp; loc, const std::basic_string&lt;class CharT, class Traits&gt;&amp; format,
const utc_time&lt;Duration&gt;&amp; tp);
template &lt;class CharT, class Traits, class Duration&gt;
std::basic_string&lt;class CharT, class Traits&gt;
format(const std::basic_string&lt;class CharT, class Traits&gt;&amp; format, const utc_time&lt;Duration&gt;&amp; tp);
template &lt;class CharT, class Traits, class Rep, class Period&gt;
std::basic_string&lt;CharT&gt;
format(const std::basic_string&lt;CharT, Traits&gt;&amp; fmt, const std::chrono::duration&lt;Rep, Period&gt;&amp; d);
@ -2101,6 +2112,14 @@ template &lt;class CharT, class Duration&gt;
std::basic_string&lt;class CharT&gt;
format(const CharT* format, const sys_time&lt;Duration&gt;&amp; tp);
template &lt;class CharT, class Duration&gt;
std::basic_string&lt;class CharT&gt;
format(const std::locale&amp; loc, const CharT* format, const utc_time&lt;Duration&gt;&amp; tp);
template &lt;class CharT, class Duration&gt;
std::basic_string&lt;class CharT&gt;
format(const CharT* format, const utc_time&lt;Duration&gt;&amp; tp);
template &lt;class CharT, class Rep, class Period&gt;
std::basic_string&lt;CharT&gt;
format(const CharT* fmt, const std::chrono::duration&lt;Rep, Period&gt;&amp; d)
@ -2254,6 +2273,30 @@ template &lt;class Duration, class CharT, class Traits&gt;
parse(const std::basic_string&lt;CharT, Traits&gt;&amp; format, local_time&lt;Duration&gt;&amp; tp,
std::chrono::minutes&amp; offset, std::basic_string&lt;CharT, Traits&gt;&amp; abbrev);
template &lt;class Duration, class CharT, class Traits&gt;
<i>unspecified istream manipulator</i>
parse(const std::basic_string&lt;CharT, Traits&gt;&amp; format, utc_time&lt;Duration&gt;&amp; tp);
template &lt;class Duration, class CharT, class Traits&gt;
<i>unspecified istream manipulator</i>
parse(const std::basic_string&lt;CharT, Traits&gt;&amp; format, utc_time&lt;Duration&gt;&amp; tp,
std::basic_string&lt;CharT, Traits&gt;&amp; abbrev);
template &lt;class Duration, class CharT, class Traits&gt;
<i>unspecified istream manipulator</i>
parse(const std::basic_string&lt;CharT, Traits&gt;&amp; format, utc_time&lt;Duration&gt;&amp; tp,
std::chrono::minutes&amp; offset);
template &lt;class Duration, class CharT, class Traits&gt;
<i>unspecified istream manipulator</i>
parse(const std::basic_string&lt;CharT, Traits&gt;&amp; format, utc_time&lt;Duration&gt;&amp; tp,
std::basic_string&lt;CharT, Traits&gt;&amp; abbrev, std::chrono::minutes&amp; offset);
template &lt;class Duration, class CharT, class Traits&gt;
<i>unspecified istream manipulator</i>
parse(const std::basic_string&lt;CharT, Traits&gt;&amp; format, utc_time&lt;Duration&gt;&amp; tp,
std::chrono::minutes&amp; offset, std::basic_string&lt;CharT, Traits&gt;&amp; abbrev);
template &lt;class Rep, class Period, class CharT, class Traits&gt;
<i>unspecified istream manipulator</i>
parse(const std::basic_string&lt;CharT, Traits&gt;&amp; format,
@ -2307,6 +2350,29 @@ template &lt;class Duration, class CharT, class Traits&gt;
parse(const CharT* format, local_time&lt;Duration&gt;&amp; tp, std::chrono::minutes&amp; offset,
std::basic_string&lt;CharT, Traits&gt;&amp; abbrev);
template &lt;class Duration, class CharT&gt;
<i>unspecified istream manipulator</i>
parse(const CharT* format, utc_time&lt;Duration&gt;&amp; tp);
template &lt;class Duration, class CharT, class Traits&gt;
<i>unspecified istream manipulator</i>
parse(const CharT* format, utc_time&lt;Duration&gt;&amp; tp,
std::basic_string&lt;CharT, Traits&gt;&amp; abbrev);
template &lt;class Duration, class CharT&gt;
<i>unspecified istream manipulator</i>
parse(const CharT* format, utc_time&lt;Duration&gt;&amp; tp, std::chrono::minutes&amp; offset);
template &lt;class Duration, class CharT, class Traits&gt;
<i>unspecified istream manipulator</i>
parse(const CharT* format, utc_time&lt;Duration&gt;&amp; tp,
std::basic_string&lt;CharT, Traits&gt;&amp; abbrev, std::chrono::minutes&amp; offset);
template &lt;class Duration, class CharT, class Traits&gt;
<i>unspecified istream manipulator</i>
parse(const CharT* format, utc_time&lt;Duration&gt;&amp; tp,
std::chrono::minutes&amp; offset, std::basic_string&lt;CharT, Traits&gt;&amp; abbrev);
template &lt;class Rep, class Period, class CharT&gt;
<i>unspecified istream manipulator</i>
parse(const CharT* format, std::chrono::duration&lt;Rep, Period&gt;&amp; d);