datefmt

datefmt provides parsing and formatting for std.datetime objects.

The format is taken from strftime: %a The abbreviated name of the day of the week. %A The full name of the day of the week. %b The abbreviated month name. %B The full month name. %C The century number (year/100) as a 2-digit integer. %d The day of the month as a decimal number (range 01 to 31). %e Like %d, the day of the month as a decimal number, but space padded. %f Fractional seconds. Will parse any precision and emit six decimal places. %F Equivalent to %Y-%m-%d (the ISO 8601 date format). %g Milliseconds of the second. %G Nanoseconds of the second. %h The hour as a decimal number using a 12-hour clock (range 01 to 12). %H The hour as a decimal number using a 24-hour clock (range 00 to 23). %I The hour as a decimal number using a 12-hour clock (range 00 to 23). %j The day of the year as a decimal number (range 001 to 366). %k The hour (24-hour clock) as a decimal number (range 0 to 23), space padded. %l The hour (12-hour clock) as a decimal number (range 1 to 12), space padded. %m The month as a decimal number (range 01 to 12). %M The minute as a decimal number (range 00 to 59). %p "AM" / "PM" (midnight is AM; noon is PM). %P "am" / "pm" (midnight is AM; noon is PM). %r Equivalent to "%I:%M:%S %p". %R Equivalent to "%H:%M". %s The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). %S The second as a decimal number (range 00 to 60). %T Equivalent to "%H:%M:%S". %u The day of the week as a decimal, range 1 to 7, Monday being 1 (formatting only). %V The ISO 8601 week number (formatting only). %w The day of the week as a decimal, range 0 to 6, Sunday being 0 (formatting only). %y The year as a decimal number without a century (range 00 to 99). %Y The year as a decimal number including the century, minimum 4 digits. %z The +hhmm or -hhmm numeric timezone (that is, the hour and minute offset from UTC). %Z The timezone name or abbreviation. Formatting only. %+ The numeric offset, or 'Z' for UTC. This is common with ISO8601 timestamps. %% A literal '%' character.

Timezone support is awkward. When time formats contain a GMT offset, that is honored. Otherwise, datefmt recognizes a subset of the timezone names defined in RFC1123.

Members

Aliases

to
alias to = std.conv.to
Undocumented in source.

Functions

format
string format(SysTime dt, Format fmt)

Format the given datetime with the given Format.

format
string format(SysTime dt, string formatString)

Format the given datetime with the given format string.

parse
SysTime parse(string data, Format fmt, immutable(TimeZone) defaultTimeZone, bool allowTrailingData)

Parse the given datetime string with the given format string.

parse
SysTime parse(string data, string formatString, immutable(TimeZone) defaultTimeZone, bool allowTrailingData)

Parse the given datetime string with the given format string.

parseISO8601
SysTime parseISO8601(string data, bool allowTrailingData)

Parse an ISO8601 date.

parseRFC1123
SysTime parseRFC1123(string data, bool allowTrailingData)

Parse an RFC1123 date.

toISO8601
string toISO8601(SysTime date)

Produce an ISO8601 date string from a SysTime.

toRFC1123
string toRFC1123(SysTime date)

Produce an RFC1123 date string from a SysTime.

tryParse
bool tryParse(string data, Format fmt, SysTime dt, immutable(TimeZone) defaultTimeZone)

Try to parse the input string according to the given pattern.

tryParse
bool tryParse(string data, string formatString, SysTime dt, immutable(TimeZone) defaultTimeZone)

Try to parse the input string according to the given pattern.

Structs

Format
struct Format

A Format is the platonic ideal of a specific format string.

Variables

ISO8601FORMAT
Format ISO8601FORMAT;

A Format suitable for ISO8601 dates.

RFC1123FORMAT
Format RFC1123FORMAT;

A Format suitable for RFC1123 dates.

Meta