DateTime Format Specifiers
Below is a list of Date Format Specifiers that are supported with our date and date-time formulas.
Spec. | Example | Description |
blank | ||
|
| The full proleptic Gregorian year, zero-padded to 4 digits. |
|
| The proleptic Gregorian year divided by 100, zero-padded to 2 digits. |
|
| The proleptic Gregorian year modulo 100, zero-padded to 2 digits. |
|
| Month number (01--12), zero-padded to 2 digits. |
|
| Abbreviated month name. Always 3 letters. |
|
| Full month name. Also accepts corresponding abbreviation in parsing. |
|
| Same as |
|
| Day number (01--31), zero-padded to 2 digits. |
| | Same as |
|
| Abbreviated weekday name. Always 3 letters. |
|
| Full weekday name. Also accepts corresponding abbreviation in parsing. |
|
| Sunday = 0, Monday = 1, ..., Saturday = 6. |
|
| Monday = 1, Tuesday = 2, ..., Sunday = 7. (ISO 8601) |
|
| Week number starting with Sunday (00--53), zero-padded to 2 digits. |
|
| Same as |
|
| Same as |
|
| Same as |
|
| Same as |
|
| Day of the year (001--366), zero-padded to 3 digits. |
|
| Month-day-year format. Same as |
|
| Locale's date representation (e.g., 12/31/99). |
|
| Year-month-day format (ISO 8601). Same as |
| | Day-month-year format. Same as |
TIME SPECIFIERS: | ||
|
| Hour number (00--23), zero-padded to 2 digits. |
| | Same as |
|
| Hour number in 12-hour clocks (01--12), zero-padded to 2 digits. |
|
| Same as |
|
|
|
|
|
|
|
| Minute number (00--59), zero-padded to 2 digits. |
|
| Second number (00--60), zero-padded to 2 digits. |
|
| The fractional seconds (in nanoseconds) since last whole second. |
|
| Similar to |
|
| Similar to |
|
| Similar to |
|
| Similar to |
|
| Similar to |
|
| Similar to |
|
| Similar to |
|
| Hour-minute format. Same as |
|
| Hour-minute-second format. Same as |
|
| Locale's time representation (e.g., 23:13:48). |
|
| Hour-minute-second format in 12-hour clocks. Same as |
TIME ZONE SPECIFIERS: | ||
|
| Local time zone name. Skips all non-whitespace characters during parsing. |
|
| Offset from the local time to UTC (with UTC being |
|
| Same as |
|
| Parsing only: Same as |
DATE & TIME SPECIFIERS: | ||
|
| Locale's date and time (e.g., Thu Mar 3 23:05:25 2005). |
|
| ISO 8601 / RFC 3339 date & time format. |
|
| UNIX timestamp, the number of seconds since 1970-01-01 00:00 UTC. |
SPECIAL SPECIFIERS: | ||
| Literal tab ( | |
| Literal newline ( | |
| Literal percent sign. |
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.
Modifier | Description |
| Suppresses any padding including spaces and zeroes. (e.g. |
| Uses spaces as a padding. (e.g. |
| Uses zeroes as a padding. (e.g. |
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