Formatter.date Class
Functions ought to format date components.
Item Index
Methods
- abbreviatedMonthName static
- abbreviatedTimezone static
- abbreviatedWeekdayName static
- dayOfMonth static
- dayOfYear static
- hours static
- milliseconds static
- minutes static
- month static
- monthName static
- seconds static
- time static
- time12 static
- timeDesignator static
- timezoneOffset static
- weekdayName static
- year static
Methods
abbreviatedMonthName
-
date -
culture
Returns the culture-specific abbreviated month name specfied by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
cultureObjectCulture information
Returns:
abbreviatedTimezone
-
date
Returns a string representing the time zone abbreviation specified by the given date.
Parameters:
-
dateDateInterpreted as a date with the same timezone as provided by the host OS.
Returns:
abbreviatedWeekdayName
-
date -
culture
Returns the culture-specific abbreviated weekday name specfied by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
cultureObjectCulture information
Returns:
dayOfMonth
-
date -
leadingZero
Returns a string representing the day of the month specified by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
leadingZeroBooleanZero padded result?
Returns:
dayOfYear
-
date -
leadingZeros
Returns a string representing the day of the year specified by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
leadingZerosBooleanZero padded result?
Returns:
hours
-
date -
leadingZero -
h12
Returns the formatted hours specified by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
leadingZeroBooleanZero padded result?
-
h12BooleanHours in [1,12]?
Returns:
milliseconds
-
date -
leadingZeros
Returns the formatted milliseconds specified by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
leadingZerosBooleanZero padded result?
Returns:
minutes
-
date -
leadingZero
Returns the formatted minutes specified by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
leadingZeroBooleanZero padded result?
Returns:
month
-
date -
leadingZero
Returns a string representing the month specified by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
leadingZeroBooleanZero padded result?
Returns:
monthName
-
date -
culture
Returns the culture-specific month name specfied by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
cultureObjectCulture information
Returns:
seconds
-
date -
leadingZero
Returns the formatted seconds specified by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
leadingZeroBooleanZero padded result?
Returns:
time
-
date -
leadingZeros
Returns a string representing the 24h time specified by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
leadingZerosBooleanZero padded time components?
Returns:
time12
-
date -
leadingZeros -
designator
Returns a string representing the 12h time specified by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
leadingZerosBooleanZero padded time components?
-
designatorBooleanIncluding time designator (AM/PM)?
Returns:
timeDesignator
-
date -
culture
Returns a string representing the morning/afternoon designator for the time specified by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
cultureObjectCulture information
Returns:
timezoneOffset
-
date
Returns a string representing the given date's time zone offset from UTC.
Parameters:
-
dateDateInterpreted as a date with the same timezone as provided by the host OS.
Returns:
weekdayName
-
date -
culture
Returns the culture-specific weekday name specfied by the given date.
Parameters:
-
dateDateInterpreted as a UTC value
-
cultureObjectCulture information
Returns:
year
-
date -
[options]
Returns a string representing the specified year.
Negative years are formatted with the prefix '-' by default. Set the
option property bcPrefix or bcPostfix to change the default behavior.
Note that setting a non-falsy postfix implies the prefix ''.
The number of digits in the resulting string depends on the option
properties maxDigits and leadingZeros.
The resulting year is zero padded if maxDigits is greater than the
number of year digits and leadingZeros is set to true.
Most significant digits of the resulting year are truncated if maxDigits
is less than the number of year digits. In that case leading zeros are
also truncated except leadingZeros is set to true.
Parameters:
-
dateDateInterpreted as a UTC value
-
[options]Object optionalFormat options. Default values are:
{ bcPrefix: '-', bcPostfix: '', leadingZeros: false maxDigits: number of year digits }
Returns:
Example:
var d = new Date('2012-01-01T00:00Z');
Formatter.date.year(d); //'2012'
Formatter.date.year(d, {maxDigits:3}); //'12'
Formatter.date.year(d, {maxDigits:3, leadingZeros:true}); //'012'
Formatter.date.year(d, {maxDigits:5, leadingZeros:true}); //'02012'
d = new Date(Date.UTC(-2012, 1));
Formatter.date.year(d); //'-2012'
Formatter.date.year(d, {bcPostfix: ' BC.'}); //'2012 BC.'
Formatter.date.year(d, {bcPrefix: 'BC.'}); //'BC.2012'
