]> git.lizzy.rs Git - rust.git/commit
Add fractional second support to str{p,f}time
authorSteven Fackler <sfackler@gmail.com>
Fri, 6 Sep 2013 06:13:02 +0000 (23:13 -0700)
committerSteven Fackler <sfackler@gmail.com>
Fri, 6 Sep 2013 06:19:41 +0000 (23:19 -0700)
commit3c30ecb706dc32257d1ec6bdcb0c88eb924483dd
treed86421c6b40f9f4e67f35c8d80d4a52ee791459f
parenta980f28028f4712efbb89017bd23c25183fddbfe
Add fractional second support to str{p,f}time

The ISO 8601 standard does not mandate any specific precision for
fractional seconds, so this accepts input of any length, ignoring the
part after the nanoseconds place. It may be more correct to round with
the tenths of nanoseconds digit, but then we'd have to deal with
carrying the round through the entire Tm struct (e.g. for a time like
Dec 31 11:59.999999999999).

%f is the format specifier that Python's datetime library uses for
0-padded microseconds so it seemed appropriate here.

cc #2350
src/libextra/time.rs