Boost C++ Libraries: Ticket #9146: chrono_io support for time format with fractional seconds https://svn.boost.org/trac10/ticket/9146 <p> I propose %f and %F is added to chrono_io in analogy with <a href="http://www.boost.org/doc/libs/1_53_0/doc/html/date_time/date_time_io.html">http://www.boost.org/doc/libs/1_53_0/doc/html/date_time/date_time_io.html</a> </p> <p> Unfortunately this is just a specification, no suggested implementation. </p> <p> Examples: </p> <pre class="wiki"> 1970-01-01 00:02:46 1970-01-01 00:02:46.7 1970-01-01 00:02:46.67 1970-01-01 00:02:46.667 </pre><p> all the way up to nanoseconds (as gnu date +%N): </p> <pre class="wiki"> 1970-01-01 00:02:46.666666667 </pre><p> (variants with T instead of space, and time-zone are the real use-cases, but that aspect already works) </p> <p> Some tools write fractional seconds only if they are not zero. date_time_io supports that using %F so I suggest that for chrono_io as well. </p> <p> To support writing all of the above formats one could allow for example %3f (and %3F) for printing .667. Alternatively, %N for nanoseconds. When parsing i suggest the number of digits specified is ignored but I may be wrong on that. </p> <p> In addition to the above, the documentation has no list of allowed keys for the format strings. </p> <p> references: </p> <ul><li>The bug <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/7868"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/7868</a> was just fixed. </li></ul><ul><li>doc: <a href="http://www.boost.org/doc/libs/1_54_0/doc/html/chrono/users_guide.html#chrono.users_guide.getting_started.hello_world">http://www.boost.org/doc/libs/1_54_0/doc/html/chrono/users_guide.html#chrono.users_guide.getting_started.hello_world</a><span class="underline"> : </span></li></ul><p> 'Unfortunately there are no formatting/parsing sequences which indicate fractional seconds. Boost.Chrono does not provide such sequences. In the meantime, one can format and parse fractional seconds for system_clock::time_point by defaulting the format, or by using an empty string in time_fmt().' </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9146 Trac 1.4.3 viboes Wed, 09 Oct 2013 20:57:35 GMT <link>https://svn.boost.org/trac10/ticket/9146#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9146#comment:1</guid> <description> <p> Hi, I have committed <a class="changeset" href="https://svn.boost.org/trac10/changeset/86221" title="Chrono: Added documentation for format tags.">[86221]</a> which contains some of the supported flags. </p> <p> In addition, %z is used to represent the fractional seconds. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 12 Oct 2013 16:00:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9146#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9146#comment:2</guid> <description> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/86265" title="Chrono: update time_point io format tags.">[86265]</a>. </p> </description> <category>Ticket</category> </item> <item> <author>Johan Lundberg <lundberj@…></author> <pubDate>Sat, 12 Oct 2013 18:47:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9146#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9146#comment:3</guid> <description> <p> Thanks for the documentation addition! </p> <p> I just downloaded the latest svn trunk (I got <a class="changeset" href="https://svn.boost.org/trac10/changeset/86264" title="* Reformatted and completed legacy code removal patches from Stephen ...">r86264</a>) and just as in previous versions %z and %Z do denote time zone (such as +0000 and 'GMT' respectively). I think that is the expected behavior (still undocumented) following date_time_io, gnu date and others. </p> <p> viboes wrote: </p> <blockquote class="citation"> <p> In addition, %z is used to represent the fractional seconds. </p> </blockquote> <p> I could not find any commit that actually added support for fractional seconds, and %z is not it. (and %f %F still prints '%f 2013-10-12') </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 15 Oct 2013 21:59:04 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/9146#comment:4 https://svn.boost.org/trac10/ticket/9146#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> What about <a href="http://www.boost.org/doc/libs/1_54_0/doc/html/chrono/reference.html#chrono.reference.io.time_point_io_hpp.streams">http://www.boost.org/doc/libs/1_54_0/doc/html/chrono/reference.html#chrono.reference.io.time_point_io_hpp.streams</a> ? </p> Ticket viboes Thu, 24 Oct 2013 21:45:49 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9146#comment:5 https://svn.boost.org/trac10/ticket/9146#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> For me, your request is already available and <a class="changeset" href="https://svn.boost.org/trac10/changeset/86265" title="Chrono: update time_point io format tags.">[86265]</a> document it. Be free to reopen this ticket if you disagree. </p> Ticket viboes Thu, 24 Oct 2013 21:45:58 GMT milestone changed https://svn.boost.org/trac10/ticket/9146#comment:6 https://svn.boost.org/trac10/ticket/9146#comment:6 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.55.0</span> </li> </ul> Ticket