View source

class thx.format.DateFormat

Available on all platforms

Class Fields

static function customFormat(d:DateTime, pattern:String, ?culture:Culture):String

Custom date format.

static function dateLong(d:DateTime, ?culture:Culture):String

Long Date/Time format.

static function dateShort(d:DateTime, ?culture:Culture):String

Short Date/Time format.

static function dateTimeFull(d:DateTime, ?culture:Culture):String

Full Date/Time format.

static function dateTimeSortable(d:DateTime, ?culture:Culture):String

Sortable Date/Time format.

static function format(d:DateTime, pattern:String, ?culture:Culture):String

Formats the date using a one letter formatting option or using a custom pattern.

patterndescription
dshort date pattern
Dlong date pattern
flong date + short time pattern
Flong date + long time pattern
gshort date + short time pattern
Gshort date + long time pattern
M, mmonth/day pattern
O, oroundtrip format
R, rRFC1123 pattern
ssortable date/time pattern
tshort time pattern
Tlong time pattern
uuniversal sortable date/time pattern
Uuniversal full date/time pattern
Y, yyear/month pattern
...custom pattern. It splits the pattern into pattern terms and apply them individually

See formatTerm for all the possible formatting options to use for custom patterns.

static function formatTerm(d:DateTime, pattern:String, ?culture:Culture):String

Returns a formatted date according to the passed term and culture. The pattern parameter accepts the following modifiers in either Microsoft format or strftime format.

formatdescriptionexample
dddThe abbreviated weekday name according to the current locale.Wed
ddddThe full weekday name according to the current locale.Wednesday
MMMThe abbreviated month name according to the current locale.Jan
MMMMThe full month name according to the current locale.January
ddThe day of the month as a decimal number (range 01 to 31).07
MMMEquivalent to %b.Jan
HHThe hour as a decimal number using a 24-hour clock (range 00 to 23).22
hhThe hour as a decimal number using a 12-hour clock (range 01 to 12).07
KSame as zzz
MMThe month as a decimal number (range 01 to 12).04
mmThe minute as a decimal number (range 00 to 59).08
ttEither 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as 'pm' and midnight as 'am'.AM
ssThe second as a decimal number (range 00 to 61). the upper level of the range 61 rather than 59 to allow for the occasional leap second and even more occasional double leap second.07
yThe year as a decimal number without a century (range 00 to 99).04
dThe day of the month (1 to 31).7
hThe hour on a 12-hour clock (1 to 12).11
HSame as h but 0 padded (01 to 12).07
mMinute (0 to 59).7
MSame as m but 0 padded (00 to 59).07
sSeconds (0 to 59).7
tSame as s but 0 padded (00 to 59).07
yyYear from 00 to 99.99
yyyYear with at least 3 digits.1999
yyyyFour digits year.1999
yyyyyFive digits year.19999
fOutputs the tenth of a second.
fffffffOutputs up to the tenth of a microsecond. the tenth of a second.
FOutputs the tenth of a second.
FFFFFFF
zTime zone offset with hours only and no padding-6
zzTime zone offset with hours only and padding-06
zzzTime zone offset with hours and minutes-06:00
:Time separator.%
/Date separator./
'...'Single quoted text is not processed (except for removing the quotes)...
"..."Double quoted text is not processed (except for removing the quotes)...
%?Delegates to strftime%d

static function iso8601(d:DateTime, ?culture:Culture):String

Format a date in way that is compatible with the iso8601 specification.

static function monthDay(d:DateTime, ?culture:Culture):String

Month/Day format.

static function rfc1123(d:DateTime, ?culture:Culture):String

Rfc1123 date/time format.

static function strftime(d:DateTime, pattern:String, ?culture:Culture):String

Format a date using a strftime term.

strftimedescriptionexample
%aThe abbreviated weekday name according to the current locale.Wed
%AThe full weekday name according to the current locale.Wednesday
%bThe abbreviated month name according to the current locale.Jan
%BThe full month name according to the current locale.January
%cThe preferred date and time representation for the current locale.
%CThe century number (year/100) as a 2-digit integer.19
%dThe day of the month as a decimal number (range 01 to 31).07
%DEquivalent to %m/%d/%y. (This is the USA date format. In many countries %d/%m/%y is the standard date format. Thus, in an international context, both of these formats are ambiguous and should be avoided).06/25/04
%eLike %d, the day of the month as a decimal number, but a leading zero may be replaced by a leadingspace." 7"
%fThe month. Single-digit months may be prefixed by leadingspace.*" 6"
%hEquivalent to %b.Jan
%HThe hour as a decimal number using a 24-hour clock (range 00 to 23).22
%iThe minute. Single-digit minutes may be prefixed by leadingspace.*" 8"
%IThe hour as a decimal number using a 12-hour clock (range 01 to 12).07
%kThe hour (24-hour clock) as a decimal number (range 0 to 23); single-digits are optionally prefixed by leadingspace. (See also %H).7
%lThe hour (12-hour clock) as a decimal number (range 1 to 12); single-digits are optionally prefixed by leadingspace. (See also %I).7
%mThe month as a decimal number (range 01 to 12).04
%MThe minute as a decimal number (range 00 to 59).08
%nA newline character.
%pEither 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as 'pm' and midnight as 'am'.AM
%PLike %p but in lowercase: 'am' or 'pm' or a corresponding string for the current locale.AM
%qThe second. Single-digit seconds may be prefixed by leadingspace.*" 9"
%rThe time in a.m. or p.m. notation. In the POSIX locale this is equivalent to '%I:%M:%S %p'.07:08:09 am
%RThe time in 24-hour notation (%H:%M). For a version including the seconds, see %T below.07:08
%sThe number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC.1099928130
%SThe second as a decimal number (range 00 to 61). the upper level of the range 61 rather than 59 to allow for the occasional leap second and even more occasional double leap second.07
%tA tab character.
%TThe time in 24-hour notation (%H:%M:%S).17:08:09
%uThe day of the week as a decimal, range 1 to 7, Monday being 1. See also %w.
%wThe day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
%xThe preferred date representation for the current locale without the time.
%XThe preferred time representation for the current locale without the date.
%yThe year as a decimal number without a century (range 00 to 99).04
%YThe year as a decimal number including the century.2004
%zThe time zone offset.
%%A literal '%' character.%

*customs for missing features

static function timeLong(d:DateTime, ?culture:Culture):String

Long time format.

static function timeShort(d:DateTime, ?culture:Culture):String

Sort time format.

static function universalSortable(d:DateTime, ?culture:Culture):String

Format a date in way that it can be correctly ordered alphabetically.

static function yearMonth(d:DateTime, ?culture:Culture):String

Format for year and month.

Toggle inherited fields