You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR introduces new options for controlling the precision
of fractional seconds when printing `Zoned`, `Timestamp`,
`civil::DateTime` or `civil::Time` values. This is principally exposed
via `jiff::fmt::temporal::DateTimePrinter::precision`, but it's also
available via the standard library's formatting machinery. For example,
if `zdt` is a `jiff::Zoned`, then `format!("{zdt:.6}")` will format
it into a string with microsecond precision, even if its fractional
component is zero.
This is useful when one wants a datetime to use a "fixed width" format.
Or at least, as close to one as possible. For `Zoned` in particular, a
fixed width format is somewhat difficult to accomplish because of the
variable length IANA time zone identifier. But if the time zone
identifier is the same for all `Zoned` values in a particular context,
then setting the precision will provide fixed width. (Unless the years
are negative.)
Closes#92
Background - fast/logforth#40 (comment)
Currently, the default formatter can cause unaligned nanosecond:
@BurntSushi suggests we can make it configurable at both:
jiff::fmt::temporal::DateTimePrinter
Record for any improvement chance.
The text was updated successfully, but these errors were encountered: