Variables | |
| mon | |
| tue | |
| wed | |
| thu | |
| fri | |
| sat | |
| const char[3][7] | SHORT_U_DAY_NAME |
| Short (three-letter) names of the days of the week. | |
| const char[][7] | LONG_L_DAY_NAME |
| Full names of the days of the week. | |
| const char[][7] | LONG_U_DAY_NAME |
| Full names of the days of the week. | |
| const char[3][13] | SHORT_L_MONTH_NAME |
| Short (three-letter) names of the months of the year. | |
| const char[3][13] | SHORT_U_MONTH_NAME |
| Short (three-letter) names of the months of the year. | |
| const char[][13] | LONG_L_MONTH_NAME |
| Full names of the months of the year. | |
| const char[][13] | LONG_U_MONTH_NAME |
| Full names of the months of the year. | |
The smjg.libs.util.datetimeformat module implements the generation of formatted date and time strings.
Usually, one will not use this module directly, but instead use the corresponding properties of the types defined in smjg.libs.util.datetime.
The letters of the basic Latin alphabet are reserved for format specifiers. Each specifier is a letter, or two or more of the same letter consecutively. The letter denotes what piece of information to format, and the capitalisation and length denote how to format it. Where alternative capitalisations are given for a single format, they denote the output capitalisation of the corresponding datum.
| Letter | Datum | Specifier | Format |
|---|---|---|---|
| Y | Year | yy |
Two digits |
yyy |
Exact required length | ||
yyyy |
Four digits (longer if necessary) | ||
YYY |
Astronomical notation (BC represented as negative numbers) | ||
| B | BC/AD | B or b |
BC if necessary |
BB or bb |
BC or AD | ||
BBB or bbb |
BCE or CE | ||
BBBB or bbbb |
BCE if necessary | ||
| M | Month | m |
numeric without leading zero |
mm |
numeric with leading zero | ||
MMM, Mmm or mmm |
abbreviated name | ||
MMMM, Mmmm or mmmm |
full name | ||
| D | Day of month | d |
no leading zero |
dd |
leading zero | ||
| T | Ordinal suffix | T or t |
Ordinal suffix (TH, ND or RD) of last formatted datum |
| W | Day of week | WWW, Www or www |
abbreviated name |
WWWW, Wwww or wwww |
full name | ||
| H | Hour | H |
24-hour without leading zero |
HH |
24-hour with leading zero | ||
h |
12-hour without leading zero | ||
hh |
12-hour with leading zero | ||
| A | AM/PM | A or a |
A or P |
AA or aa |
AM or PM | ||
| I | Minute | i |
no leading zero |
ii |
leading zero | ||
| S | Second | s |
no leading zero |
ss |
leading zero | ||
| F | Fraction of a second | f |
deciseconds |
FF |
centiseconds with leading zero | ||
ff |
centiseconds without leading zero | ||
FFF |
milliseconds with leading zero | ||
fff |
milliseconds without leading zero | ||
| Z | Time zone | zzzz |
offset from UTC |
| Format string | Sample formatted date/time |
|---|---|
dd/mm/yy |
08/09/05 |
Www dt Mmm yyyy BB |
Thu 8th Sep 2005 AD |
h:ii AA |
4:51 PM |
yyyy-mm-dd HH:ii:ss zzzz |
2005-09-08 16:51:09 +0100 |
Any non-alphabetic character that doesn't have a special meaning is a literal, i.e. it will be placed as is in the generated string. You can literalise a single character by placing a backquote (`) immediately before it, or any number of consecutive characters by enclosing them in single quotes ('...').
All letters of the basic Latin alphabet, even those that are not defined as format specifiers, must be literalised if they are to occur as are in the generated string. This is to prevent accidental use of letters that may become format specifiers in future versions of the notation.
The following characters will always be literals: - : , . / space and all Unicode codepoints beyond U+007F.
Curly brackets ({ }) can be used to create a collapsible portion. This is a portion that will appear in the output only if at least one of the format specifiers within it actually generates something. Under the current spec, the only conditions in which a format specifier may generate nothing are:
B, b, BBBB or bbbb specifier is used, and the date is AD.
d Mmm yyy{ B}{ HH:ii:ss zzzz}Formats the date, and the time if present, with only one space between them whether the date is BC or AD.
{d }{Mmm }yyy BBFor applications in which an exact date, the month and year or just the year may be known, to prevent leading spaces.
HH:ii{:ss}{.FFF}For applications in which a time is always known to the precision of minutes, but may sometimes be known more precisely.
| const char [][7] smjg::libs::util::datetimeformat.LONG_L_DAY_NAME |
Initial value:
[
DAY_OF_WEEK.SUN: "sunday", "monday", "tuesday", "wednesday",
"thursday", "friday", "saturday"
]
| const char [][13] smjg::libs::util::datetimeformat.LONG_L_MONTH_NAME |
Initial value:
[
null, MONTH.JAN: "january", "february", "march", "april", "may", "june",
"july", "august", "september", "october", "november", "december"
]
| const char [][7] smjg::libs::util::datetimeformat.LONG_U_DAY_NAME |
Initial value:
[
DAY_OF_WEEK.SUN: "SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY",
"THURSDAY", "FRIDAY", "SATURDAY"
]
| const char [][13] smjg::libs::util::datetimeformat.LONG_U_MONTH_NAME |
Initial value:
[
null, MONTH.JAN: "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE",
"JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"
]
| const char [3][13] smjg::libs::util::datetimeformat.SHORT_L_MONTH_NAME |
Initial value:
[
"\xFF\xFF\xFF",
MONTH.JAN: "jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "oct", "nov", "dec"
]
| const char [3][7] smjg::libs::util::datetimeformat.SHORT_U_DAY_NAME |
Initial value:
[
DAY_OF_WEEK.SUN: "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
]
| const char [3][13] smjg::libs::util::datetimeformat.SHORT_U_MONTH_NAME |
Initial value:
[
"\xFF\xFF\xFF",
MONTH.JAN: "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
]
1.5.3