format
type format
A time formatter type for formatting and parsing UTC dates and times. A rell.time.format value is constructed from format pattern text. The resulting value can then be used to format a unix timestamp according to the format pattern text, or the inverse, i.e. to parse a timestamp from text that is formatted according to the format pattern text, returning a unix timestamp.
The following format specifiers are supported:
| Specifier | Meaning |
|---|---|
y | Year |
M | Month in the year |
w | Week in the year |
W | Week in the month |
D | Day in the year |
d | Day in the month |
E | Day name in the week |
u | Day number in the week |
a | AM/PM specifier |
H | Hour in the day (0-23) |
h | Hour in the am/pm (1-12) |
m | Minute in the hour |
s | Second in the minute |
S | Milliseconds in the second |
Non-interpreted text may be included within 'single quotes'. A single quote is escaped with a second single quote (i.e. '').
Examples:
rell.time.format('yyyy.MM.dd \'at\' HH:mm:ss').text_to_ms('2001.07.04 at 11:08:56') // returns 994244936000
rell.time.format('EEE, MMM d, \'\'yy').text_to_ms('Wed, Jul 4, \'01') // returns 994204800000
rell.time.format('h:mm a').text_to_ms('11:08 AM') // returns 40080000
rell.time.format('hh \'o\'\'clock\' a').text_to_ms('11 o\'clock AM') // returns 39600000
val ms: integer = 994244936235;
rell.time.format('hh:mm a').ms_to_text(ms) // returns '11:08 AM'
rell.time.format('yyyyy.MMMMM.dd hh:mm aaa').ms_to_text(ms) // returns '02001.July.04 11:08 AM'
rell.time.format('yyyy-MM-dd\'T\'HH:mm:ss.SSS').ms_to_text(ms) // returns '2001-07-04T11:08:56.235'
rell.time.format('yyyy-\'W\'ww-u').ms_to_text(ms) // returns '2001-W27-3'Content copied to clipboard
Since
0.14.14