# new TimeZone(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Object
|
Options guiding the construction of this time zone instance |
Methods
# getCountry() → {string}
Returns the ISO 3166 code of the country for which this time zone is defined.
the ISO 3166 code of the country for this zone
string
# getDSTSavings() → {Object.<{h:number, m:number, s:number}>}
Return the amount of time in hours:minutes that the clock is advanced during daylight savings time.
the amount of time that the clock advances for DST in hours, minutes, and seconds
Object.<{h:number, m:number, s:number}>
# getDSTSavingsStr() → {string}
Return the amount of time in hours:minutes that the clock is advanced during daylight savings time.
the amount of time that the clock advances for DST in the format "h:m:s"
string
# getDisplayName(date, styleopt) → {string}
Return the abbreviation that is used for the current time zone on the given date. The date may be in DST or during standard time, and many zone names have different abbreviations depending on whether or not the date is falls within DST.
There are two styles that are supported:
- standard - returns the 3 to 5 letter abbreviation of the time zone name such as "CET" for "Central European Time" or "PDT" for "Pacific Daylight Time"
- rfc822 - returns an RFC 822 style time zone specifier, which specifies more explicitly what the offset is from UTC
- long - returns the long name of the zone in English
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
date |
IDate
|
Object
|
JulianDay
|
Date
|
string
|
number
|
a date to determine if it is in daylight time or standard time |
|
style |
string
|
<optional> |
one of "standard" or "rfc822". Default if not specified is "standard" |
the name of the time zone, abbreviated according to the style
string
# getId() → {string}
Return the id used to uniquely identify this time zone.
a unique id for this time zone
string
# getOffset(date) → {Object.<{h:number, m:number}>}
Returns the offset of this time zone from UTC at the given date/time. If daylight saving time is in effect at the given date/time, this method will return the offset value adjusted by the amount of daylight saving.
Parameters:
Name | Type | Description |
---|---|---|
date |
IDate
|
Object
|
JulianDay
|
Date
|
string
|
number
|
the date for which the offset is needed |
an object giving the offset for the zone at the given date/time, in hours, minutes, and seconds
Object.<{h:number, m:number}>
# getOffsetMillis(date) → {number}
Returns the offset of this time zone from UTC at the given date/time expressed in milliseconds. If daylight saving time is in effect at the given date/time, this method will return the offset value adjusted by the amount of daylight saving. Negative numbers indicate offsets west of UTC and conversely, positive numbers indicate offset east of UTC.
Parameters:
Name | Type | Description |
---|---|---|
date |
IDate
|
Object
|
JulianDay
|
Date
|
string
|
number
|
the date for which the offset is needed, or null for the present date |
the number of milliseconds of offset from UTC that the given date is
number
# getOffsetStr(date) → {string}
Returns the offset of this time zone from UTC at the given date/time. If daylight saving time is in effect at the given date/time, this method will return the offset value adjusted by the amount of daylight saving.
Parameters:
Name | Type | Description |
---|---|---|
date |
IDate
|
Object
|
JulianDay
|
Date
|
string
|
number
|
the date for which the offset is needed |
the offset for the zone at the given date/time as a string in the format "h:m:s"
string
# getRawOffset() → {Object.<{h:number, m:number, s:number}>}
Gets the offset from UTC for this time zone.
an object giving the offset from UTC for this time zone, in hours, minutes, and seconds
Object.<{h:number, m:number, s:number}>
# getRawOffsetMillis() → {number}
Gets the offset from UTC for this time zone expressed in milliseconds. Negative numbers indicate zones west of UTC, and positive numbers indicate zones east of UTC.
an number giving the offset from UTC for this time zone in milliseconds
number
# getRawOffsetStr() → {string}
Gets the offset from UTC for this time zone without DST savings.
the offset from UTC for this time zone, in the format "h:m:s"
string
# inDaylightTime(date, wallTimeopt) → {boolean}
Returns whether or not the given date is in daylight saving time for the current zone. Note that daylight savings time is observed for the summer. Because the seasons are reversed, daylight savings time in the southern hemisphere usually runs from the end of the year through New Years into the first few months of the next year. This method will correctly calculate the start and end of DST for any location.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
date |
IDate
|
Object
|
JulianDay
|
Date
|
string
|
number
|
a date for which the info about daylight time is being sought, or undefined to tell whether we are currently in daylight savings time |
|
wallTime |
boolean
|
<optional> |
if true, then the given date is in wall time. If false or undefined, it is in the usual UTC time. |
true if the given date is in DST for the current zone, and false otherwise.
boolean
# useDaylightTime(year) → {boolean}
Returns true if this time zone switches to daylight savings time at some point in the year, and false otherwise.
Parameters:
Name | Type | Description |
---|---|---|
year |
number
|
Whether or not the time zone uses daylight time in the given year. If this parameter is not given, the current year is assumed. |
true if the time zone uses daylight savings time
boolean
# static getAvailableIds(country, sync, onLoad) → {Array.<string>}
Return an array of available zone ids that the constructor knows about. The country parameter is optional. If it is not given, all time zones will be returned. If it specifies a country code, then only time zones for that country will be returned.
Parameters:
Name | Type | Description |
---|---|---|
country |
string
|
undefined
|
country code for which time zones are being sought |
sync |
boolean
|
whether to find the available ids synchronously (true) or asynchronously (false) |
onLoad |
function
|
callback function to call when the data is finished loading |
an array of zone id strings
Array.<string>