i18n.TimeZone Extends
TimeZone class implemented a time zone resolution and name information source for client applications. The time zone object is initiated from a time zone information object. Application can initiate a time zone statically, or it may choose to initiate from a data obtained from server. Each time zone information array is small, but the whole set of data is too much for client application to download. If end user is allowed to change time zone setting, dynamic retrieval should be the method to use. In case only time zone offset is known, there is a decent fallback that only use the time zone offset to create a TimeZone object. A whole set of time zone information array was available under http://go/js_locale_data. It is generated based on CLDR and Olson time zone data base (through pytz), and will be updated timely.

Inheritance

Constructor

goog.i18n.TimeZone()

Instance Methods

Public Protected Private
getDaylightAdjustment(date) number
Return the DST adjustment to the time zone offset for a given time. While Daylight Saving Time is in effect, this number is positive. Otherwise, it is zero.
Arguments:
date : goog.date.DateLike
The time to check.
Returns: number  The DST adjustment in minutes EAST of UTC.
code »
getGMTString(date) string
Return the GMT representation of this time zone object.
Arguments:
date : goog.date.DateLike
The date for which time to retrieve GMT string.
Returns: string  GMT representation string.
code »
getLongName(date) string
Get the long time zone name for a given date/time.
Arguments:
date : goog.date.DateLike
The time for which to retrieve the long time zone name.
Returns: string  The long time zone name.
code »
getOffset(date) number
Get the time zone offset in minutes WEST of UTC for a given date/time.
Arguments:
date : goog.date.DateLike
The time for which to retrieve the time zone offset.
Returns: number  The time zone offset in minutes WEST of UTC.
code »
getRFCTimeZoneString(date) string
Get the RFC representation of the time zone for a given date/time.
Arguments:
date : goog.date.DateLike
The time for which to retrieve the RFC time zone string.
Returns: string  The RFC time zone string.
code »
getShortName(date) string
Get the short time zone name for given date/time.
Arguments:
date : goog.date.DateLike
The time for which to retrieve the short time zone name.
Returns: string  The short time zone name.
code »
getTimeZoneData() !Object
Convert the contents of time zone object to a timeZoneData object, suitable for passing to goog.i18n.TimeZone.createTimeZone.
Returns: !Object  A timeZoneData object (see the documentation for goog.i18n.TimeZone.createTimeZone).
code »
getTimeZoneId() string
Return the time zone ID for this time zone.
Returns: string  The time zone ID.
code »
isDaylightTime(date) boolean
Check if Daylight Saving Time is in effect at a given time in this time zone.
Arguments:
date : goog.date.DateLike
The time to check.
Returns: boolean  True if Daylight Saving Time is in effect.
code »

Instance Properties

standardOffset_ :
The standard, non-daylight time zone offset, in minutes WEST of UTC.
Code »
timeZoneId_ :
The standard time zone id.
Code »
transitions_ :
This array specifies the Daylight Saving Time transitions for this time zone. This is a flat array of numbers which are interpreted in pairs: [time1, adjustment1, time2, adjustment2, ...] where each time is a DST transition point given as a number of hours since 00:00 UTC, January 1, 1970, and each adjustment is the adjustment to apply for times after the DST transition, given as minutes EAST of UTC.
Code »
tzNames_ :
An array of strings that can have 2 or 4 elements. The first two elements are the long and short names for standard time in this time zone, and the last two elements (if present) are the long and short names for daylight time in this time zone.
Code »

Static Methods

goog.i18n.TimeZone.composeGMTString_(offset) string
Generate a GMT-relative string for a constant time zone offset.
Arguments:
offset : number
The time zone offset in minutes WEST of UTC.
Returns: string  The GMT string for this offset, which will indicate hours EAST of UTC.
code »
goog.i18n.TimeZone.composePosixTimeZoneID_(offset) string
Generate a POSIX time zone ID for a constant time zone offset.
Arguments:
offset : number
The time zone offset in minutes WEST of UTC.
Returns: string  The POSIX time zone ID for this offset, which will indicate hours WEST of UTC.
code »
goog.i18n.TimeZone.composeUTCString_(offset) string
Generate a UTC-relative string for a constant time zone offset.
Arguments:
offset : number
The time zone offset in minutes WEST of UTC.
Returns: string  The UTC string for this offset, which will indicate hours EAST of UTC.
code »
goog.i18n.TimeZone.createSimpleTimeZone_(timeZoneOffsetInMinutes) !goog.i18n.TimeZone
This factory method creates a time zone object with a constant offset.
Arguments:
timeZoneOffsetInMinutes : number
Offset in minutes WEST of UTC.
Returns: !goog.i18n.TimeZone  A time zone object with the given constant offset. Note that the time zone ID of this object will use the POSIX convention, which has a reversed sign ("Etc/GMT+8" means UTC-8 or PST).
code »
goog.i18n.TimeZone.createTimeZone(timeZoneData) !goog.i18n.TimeZone
This factory method creates a time zone instance. It takes either an object containing complete time zone information, or a single number representing a constant time zone offset. If the latter form is used, DST functionality is not available.
Arguments:
timeZoneData : number | Object
If this parameter is a number, it should indicate minutes WEST of UTC to be used as a constant time zone offset. Otherwise, it should be an object with these four fields:
  • id: A string ID for the time zone.
  • std_offset: The standard time zone offset in minutes EAST of UTC.
  • names: An array of four names (standard short name, standard long name, daylight short name, daylight long, name)
  • transitions: An array of numbers which are interpreted in pairs: [time1, adjustment1, time2, adjustment2, ...] where each time is a DST transition point given as a number of hours since 00:00 UTC, January 1, 1970, and each adjustment is the adjustment to apply for times after the DST transition, given as minutes EAST of UTC.
Returns: !goog.i18n.TimeZone  A goog.i18n.TimeZone object for the given time zone data.
code »

Static Properties

goog.i18n.TimeZone.MILLISECONDS_PER_HOUR_ :
The number of milliseconds in an hour.
Code »

Enumerations

goog.i18n.TimeZone.NameType :
Indices into the array of time zone names.
Constants:
DLT_LONG_NAME
No description.
DLT_SHORT_NAME
No description.
STD_LONG_NAME
No description.
STD_SHORT_NAME
No description.
Code »

Package i18n

Package Reference