dojo/date/locale (version 1.10)

Summary

This modules defines dojo/date/locale, localization methods for Date.

See the dojo/date/locale reference documentation for more information.

Method Summary

  • __FormatOptions()
  • _getDayOfYear(dateObject) gets the day of the year as represented by dateObject
  • _getGregorianBundle(locale)
  • _getWeekOfYear(dateObject,firstDayOfWeek)
  • _getZone(dateObject,getName,options) Returns the zone (or offset) for the given date and options.
  • _parseInfo(options)
  • addCustomFormats(packageName,bundleName) Add a reference to a bundle containing localized custom formats to be used by date/time formatting and parsing routines.
  • format(dateObject,options) Format a Date object as a String, using locale-specific settings.
  • getNames(item,type,context,locale) Used to get localized strings from dojo.cldr for day or month names.
  • isWeekend(dateObject,locale) Determines if the date falls on a weekend, according to local custom.
  • parse(value,options) Convert a properly formatted string to a primitive Date object, using locale-specific settings.
  • regexp(options) Builds the regular needed to parse a localized date

Methods

__FormatOptions()
Defined by dojo/date/locale
_getDayOfYear(dateObject)
Defined by dojo/date/locale

gets the day of the year as represented by dateObject

Parameter Type Description
dateObject Date
Returns:number
_getGregorianBundle(locale)
Defined by dojo/date/locale
Parameter Type Description
locale String
Returns:object
_getWeekOfYear(dateObject,firstDayOfWeek)
Defined by dojo/date/locale
Parameter Type Description
dateObject Date
firstDayOfWeek Number
Returns:undefined
_getZone(dateObject,getName,options)
Defined by dojo/date/locale

Returns the zone (or offset) for the given date and options. This is broken out into a separate function so that it can be overridden by timezone-aware code.

Parameter Type Description
dateObject Date

the date and/or time being formatted.

getName boolean

Whether to return the timezone string (if true), or the offset (if false)

options Object
Optional

The options being used for formatting

Returns:undefined
_parseInfo(options)
Defined by dojo/date/locale
Parameter Type Description
options Object
Optional

An object with the following properties:

  • selector (String):

    choice of 'time','date' (default: date and time)

  • formatLength (String):

    choice of long, short, medium or full (plus any custom additions). Defaults to 'short'

  • datePattern (String):

    override pattern with this string

  • timePattern (String):

    override pattern with this string

  • am (String):

    override strings for am in times

  • pm (String):

    override strings for pm in times

  • locale (String):

    override the locale used to determine formatting rules

  • fullYear (Boolean):

    (format only) use 4 digit years whenever 2 digit years are called for

  • strict (Boolean):

    (parse only) strict parsing, off by default

Returns:object
addCustomFormats(packageName,bundleName)
Defined by dojo/date/locale

Add a reference to a bundle containing localized custom formats to be used by date/time formatting and parsing routines.

The user may add custom localized formats where the bundle has properties following the same naming convention used by dojo.cldr: dateFormat-xxxx / timeFormat-xxxx The pattern string should match the format used by the CLDR. See dojo/date/locale.format() for details. The resources must be loaded by dojo.requireLocalization() prior to use

Parameter Type Description
packageName String
bundleName String
format(dateObject,options)
Defined by dojo/date/locale

Format a Date object as a String, using locale-specific settings.

Create a string from a Date object using a known localized pattern. By default, this method formats both date and time from dateObject. Formatting patterns are chosen appropriate to the locale. Different formatting lengths may be chosen, with "full" used by default. Custom patterns may be used or registered with translations using the dojo/date/locale.addCustomFormats() method. Formatting patterns are implemented using the syntax described at unicode.org

Parameter Type Description
dateObject Date

the date and/or time to be formatted. If a time only is formatted, the values in the year, month, and day fields are irrelevant. The opposite is true when formatting only dates.

options Object
Optional

An object with the following properties:

  • selector (String):

    choice of 'time','date' (default: date and time)

  • formatLength (String):

    choice of long, short, medium or full (plus any custom additions). Defaults to 'short'

  • datePattern (String):

    override pattern with this string

  • timePattern (String):

    override pattern with this string

  • am (String):

    override strings for am in times

  • pm (String):

    override strings for pm in times

  • locale (String):

    override the locale used to determine formatting rules

  • fullYear (Boolean):

    (format only) use 4 digit years whenever 2 digit years are called for

  • strict (Boolean):

    (parse only) strict parsing, off by default

Returns:undefined
getNames(item,type,context,locale)
Defined by dojo/date/locale

Used to get localized strings from dojo.cldr for day or month names.

Parameter Type Description
item String

'months' || 'days'

type String

'wide' || 'abbr' || 'narrow' (e.g. "Monday", "Mon", or "M" respectively, in English)

context String
Optional

'standAlone' || 'format' (default)

locale String
Optional

override locale used to find the names

Returns:undefined
isWeekend(dateObject,locale)
Defined by dojo/date/locale

Determines if the date falls on a weekend, according to local custom.

Parameter Type Description
dateObject Date
Optional
locale String
Optional
Returns:boolean
parse(value,options)
Defined by dojo/date/locale

Convert a properly formatted string to a primitive Date object, using locale-specific settings.

Create a Date object from a string using a known localized pattern. By default, this method parses looking for both date and time in the string. Formatting patterns are chosen appropriate to the locale. Different formatting lengths may be chosen, with "full" used by default. Custom patterns may be used or registered with translations using the dojo/date/locale.addCustomFormats() method.

Formatting patterns are implemented using the syntax described at unicode.org When two digit years are used, a century is chosen according to a sliding window of 80 years before and 20 years after present year, for both yy and yyyy patterns. year < 100CE requires strict mode.

Parameter Type Description
value String

A string representation of a date

options Object
Optional

An object with the following properties:

  • selector (String):

    choice of 'time','date' (default: date and time)

  • formatLength (String):

    choice of long, short, medium or full (plus any custom additions). Defaults to 'short'

  • datePattern (String):

    override pattern with this string

  • timePattern (String):

    override pattern with this string

  • am (String):

    override strings for am in times

  • pm (String):

    override strings for pm in times

  • locale (String):

    override the locale used to determine formatting rules

  • fullYear (Boolean):

    (format only) use 4 digit years whenever 2 digit years are called for

  • strict (Boolean):

    (parse only) strict parsing, off by default

Returns:null | undefined
regexp(options)
Defined by dojo/date/locale

Builds the regular needed to parse a localized date

Parameter Type Description
options Object
Optional

An object with the following properties:

  • selector (String):

    choice of 'time','date' (default: date and time)

  • formatLength (String):

    choice of long, short, medium or full (plus any custom additions). Defaults to 'short'

  • datePattern (String):

    override pattern with this string

  • timePattern (String):

    override pattern with this string

  • am (String):

    override strings for am in times

  • pm (String):

    override strings for pm in times

  • locale (String):

    override the locale used to determine formatting rules

  • fullYear (Boolean):

    (format only) use 4 digit years whenever 2 digit years are called for

  • strict (Boolean):

    (parse only) strict parsing, off by default

Returns:undefined
Error in the documentation? Can’t find what you are looking for? Let us know!