String parsing and formatting directives - FObersteiner/zdt GitHub Wiki
string parsing, string generation
Available (β), planned (o) and not-planned (-) directives as of zdt
v0.3.5:
directive | parse | format | example | meaning (see also: technical notes) |
---|---|---|---|---|
%d | β | β | 01, 02, β¦, 31 | Day of the month as a zero-padded decimal number. |
%e | β (%d) | β | 1, 2, β¦, 31 | Day of the month as a space-padded decimal number. |
%a | (β) | β | Sun, Mon, β¦, Sat (en_US); So, Mo, β¦, Sa (de_DE) | Weekday as localeβs abbreviated name. (1) |
%:a | β | β | Sun, Mon, β¦, Sat | English name of weekday, abbreviated. |
%A | (β) | β | Sunday, Monday, β¦, Saturday (en_US); Sonntag, Montag, β¦, Samstag (de_DE) | Weekday as localeβs full name. (1) |
%:A | β | β | Sunday, Monday, β¦, Saturday | English name of weekday. |
%m | β | β | 01, 02, β¦, 12 | Month as a zero-padded decimal number. |
%b | (β) | β | Jan, Feb, β¦, Dec (en_US); Jan, Feb, β¦, Dez (de_DE) | Month as localeβs abbreviated name. |
%:b | β | β | Jan, Feb, β¦, Dec | Month as English abbreviated name. |
%B | (β) | β | January, February, β¦, December (en_US); Januar, Februar, β¦, Dezember (de_DE) | Month as localeβs full name. |
%:B | β | β | January, February, β¦, December | Month as English full name. |
%Y | β | β | 0001, 0002, β¦, 2013, 2014, β¦, 9998, 9999 | Year with century as a decimal number. |
%y | β | β | 00, 01, β¦, 99 | Year without century as a zero-padded decimal number (year%100). Assumes the current century. |
%C | - | β | 00, 01, β¦, 99 | Century as a zero-padded 2-digit number (year/100) |
%G | o | β | 0001, 0002, β¦, 2013, 2014, β¦, 9998, 9999 | ISO 8601 year with century representing the year that contains the greater part of the ISO week (%V). |
%H | β | β | 00, 01, β¦, 23 | Hour (24-hour clock) as a zero-padded decimal number. |
%k | β (%H) | β | 1, β¦, 23 | Hour (24-hour clock) as a space-padded decimal number. |
%I | β | β | 01, 02, β¦, 12 | Hour (12-hour clock) as a zero-padded decimal number. |
%P | β (%p) | β | AM, PM | am or pm identifier, upper-case |
%p | β | β | am, pm | am or pm identifier, lower-case |
%M | β | β | 00, 01, β¦, 59 | Minute as a zero-padded decimal number. |
%S | β | β | 00, 01, β¦, 60 | Second as a zero-padded decimal number. |
%f | β | β | 000000000, 000000001, β¦, 999999999 | Fractional seconds with nanosecond precision, zero-padded to 9 digits. |
%:f | β (%f) | β | 999 | Fractional seconds with millisecond precision, zero-padded to 3 digits. |
%::f | β (%f) | β | 999999 | Fractional seconds with microsecond precision, zero-padded to 6 digits. |
%z | β | β | +0000 | UTC offset in the form (+ |
%:z | β (%z) | β | +10:30 | see βzβ |
%::z | β (%z) | β | -03:07:12 | see βzβ |
%:::z | β (%z) | β | +01 | see βzβ |
%Z | - | β | (empty), EST, Z | Time zone abbreviation. Naive datetime gives empty string. |
%:Z | - | β | (empty), EST, UTC | Displays UTC as βUTCβ instead of βZβ, otherwise behaves like %Z. |
%i | - | β | Europe/Berlin, Asia/Kolkata | IANA time zone identifier. Gives empty string if not defined for given datetime. |
%j | β | β | 001, 002, β¦, 366 | Day of the year as a zero-padded decimal number. |
%w | o | β | 0, 1, β¦, 6 | Weekday as a decimal number, where 0 is Sunday and 6 is Saturday. |
%u | o | β | 1, 2, β¦, 7 | ISO 8601 weekday as a decimal number where 1 is Monday. |
%W | o | β | 00, 01, β¦, 53 | Week number of the year (Monday as the first day of the week) as a zero-padded decimal number. All days in a new year preceding the first Monday are considered to be in week 0. |
%U | o | β | 00, 01, β¦, 53 | Week number of the year (Sunday as the first day of the week) as a zero-padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. |
%V | o | β | 01, 02, β¦, 53 | ISO 8601 week as a decimal number with Monday as the first day of the week. Week 01 is the week containing Jan 4. |
%T | β | β | 2022-08-01T12:24:19.008993841+02:00 | ISO 8601 date and time with optional fractional seconds (if not zero) and UTC offset (if time zone / UTC offset defined) |
%t | β | β | 2022-W07-4 | ISO calendar format. |
%c | - | o | Tue Aug 16 21:30:00 1988 (en_US); Di 16 Aug 21:30:00 1988 (de_DE) | Localeβs appropriate date and time representation. |
%x | - | o | 08/16/88 (None); 08/16/1988 (en_US); 16.08.1988 (de_DE) | Localeβs appropriate date representation. |
%X | - | o | 21:30:00 (en_US); 21:30:00 (de_DE) | Localeβs appropriate time representation. |
%% | β | β | % | A literal '%' character. |
Technical notes
(1) Parsing: if a day name is supplied together with a date, the day name is not validated against that date.