DateTime Format Specifiers
Below is a list of Date Format Specifiers that are supported with our date and date-time formulas.
It is possible to override the default padding behavior of numeric specifiers %?
. This is not allowed for other specifiers and will result in the BAD_FORMAT
error.
Notes:
%Y
: Negative years are allowed in formatting but not in parsing.%C
,%y
: This is floor division, so 100 BCE (year number -99) will print-1
and99
respectively.%U
: Week 1 starts with the first Sunday in that year. It is possible to have week 0 for days before the first Sunday.%G
,%g
,%V
: Week 1 is the first week with at least 4 days in that year. Week 0 does not exist, so this should be used with%G
or%g
.%S
: It accounts for leap seconds, so60
is possible.%f
,%.f
,%.3f
,%.6f
,%.9f
,%3f
,%6f
,%9f
: The default%f
is right-aligned and always zero-padded to 9 digits for the compatibility with glibc and others, so it always counts the number of nanoseconds since the last whole second. E.g. 7ms after the last second will print007000000
, and parsing7000000
will yield the same. The variant%.f
is left-aligned and print 0, 3, 6 or 9 fractional digits according to the precision. E.g. 70ms after the last second under%.f
will print.070
(note: not.07
), and parsing.07
,.070000
etc. will yield the same. Note that they can print or read nothing if the fractional part is zero or the next character is not.
. The variant%.3f
,%.6f
and%.9f
are left-aligned and print 3, 6 or 9 fractional digits according to the number precedingf
. E.g. 70ms after the last second under%.3f
will print.070
(note: not.07
), and parsing.07
,.070000
etc. will yield the same. Note that they can read nothing if the fractional part is zero or the next character is not.
however will print with the specified length. The variant%3f
,%6f
and%9f
are left-aligned and print 3, 6 or 9 fractional digits according to the number precedingf
, but without the leading dot. E.g. 70ms after the last second under%3f
will print070
(note: not07
), and parsing07
,070000
etc. will yield the same. Note that they can read nothing if the fractional part is zero.%Z
: Offset will not be populated from the parsed data, nor will it be validated. Timezone is completely ignored. Similar to the glibcstrptime
treatment of this format code. It is not possible to reliably convert from an abbreviation to an offset, for example CDT can mean either Central Daylight Time (North America) or China Daylight Time.%+
: Same as%Y-%m-%dT%H:%M:%S%.f%:z
, i.e. 0, 3, 6 or 9 fractional digits for seconds and colons in the time zone offset. The typicalstrftime
implementations have different (and locale-dependent) formats for this specifier. While Chrono's format for%+
is far more stable, it is best to avoid this specifier if you want to control the exact output.%s
: This is not padded and can be negative. For the purpose of Chrono, it only accounts for non-leap seconds so it slightly differs from ISO Cstrftime
behavior.
Blanks
In formulas which allow for an input format string, the field can be left blank. If the field is blank, Osmos will attempt to infer the date formats from the input data. Osmos will test these formats (ignoring additional characters like "-", "/", etc.) in this order: "%m%d%y", "%m%d%Y", "%Y%m%d", "%d%b%y", "%d%b%Y", "%d%m%Y", "%d%m%y"
Note: This information is from the Rust Documentation for Date and Time Formatting.
Last updated