#9146 closed Feature Requests (fixed)
chrono_io support for time format with fractional seconds
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.55.0 | Component: | chrono |
Version: | Boost 1.54.0 | Severity: | Problem |
Keywords: | Cc: |
Description
I propose %f and %F is added to chrono_io in analogy with http://www.boost.org/doc/libs/1_53_0/doc/html/date_time/date_time_io.html
Unfortunately this is just a specification, no suggested implementation.
Examples:
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
all the way up to nanoseconds (as gnu date +%N):
1970-01-01 00:02:46.666666667
(variants with T instead of space, and time-zone are the real use-cases, but that aspect already works)
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.
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.
In addition to the above, the documentation has no list of allowed keys for the format strings.
references:
- The bug https://svn.boost.org/trac/boost/ticket/7868 was just fixed.
'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().'
Change History (6)
comment:1 by , 9 years ago
comment:3 by , 9 years ago
Thanks for the documentation addition!
I just downloaded the latest svn trunk (I got r86264) 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.
viboes wrote:
In addition, %z is used to represent the fractional seconds.
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')
comment:4 by , 9 years ago
Status: | new → assigned |
---|
comment:5 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
For me, your request is already available and [86265] document it. Be free to reopen this ticket if you disagree.
comment:6 by , 9 years ago
Milestone: | To Be Determined → Boost 1.55.0 |
---|
Hi, I have committed [86221] which contains some of the supported flags.
In addition, %z is used to represent the fractional seconds.