Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#9146 closed Feature Requests (fixed)

chrono_io support for time format with fractional seconds

Reported by: Johan Lundberg <lundberj@…> 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:

'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 viboes, 9 years ago

Hi, I have committed [86221] which contains some of the supported flags.

In addition, %z is used to represent the fractional seconds.

comment:2 by viboes, 9 years ago

Committed revision [86265].

comment:3 by Johan Lundberg <lundberj@…>, 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:5 by viboes, 9 years ago

Resolution: fixed
Status: assignedclosed

For me, your request is already available and [86265] document it. Be free to reopen this ticket if you disagree.

comment:6 by viboes, 9 years ago

Milestone: To Be DeterminedBoost 1.55.0
Note: See TracTickets for help on using tickets.