Construct a new timezone.
The timezone name.
Get the name of the timezone.
Makes a new date by taking the date parts using this timezone and making the date with the supplied time zone.
A date
A timezone
A new date using the date parts from this timezone, constructed with the supplied timezone.
Extract the date parts.
If more than one date part is required this is the preferred way to get them, as the timezone calculation is only performed once.
const {
year,
month,
day,
weekday,
hours,
minutes,
seconds,
milliseconds
} = tz.dateParts(date)
The date.
The date parts.
The day of the month for the given date.
import { tzUtc } from '@jetblack/date-tz'
const date = tzUtc.makeDate(2000, 0, 1)
console.log(tzUtc.day(date))
// returns 1
The date.
The day of the month.
The hour of the day for the given date.
import { tzUtc } from '@jetblack/date-tz'
const date = tzUtc.makeDate(2000, 0, 1, 12, 15, 30, 123)
console.log(tzUtc.hours(date))
// returns 12
The date.
The hour of the day.
Find if the date was subject to daylight savings time.
The date.
True if the date was subject to daylight savings time.
Create a date from its component parts.
The year.
The month.
The day of the month.
The hour of the day.
The minute of the day.
The second of the day.
The millisecond of the day.
A new date built from the parts.
The millisecond of the day for a given date.
import { tzUtc } from '@jetblack/date-tz'
const date = tzUtc.makeDate(2000, 0, 1, 12, 15, 30, 123)
console.log(tzUtc.milliseconds(date))
// returns 123
The date.
The milliseconds of the day.
The minute of the day for the given date.
import { tzUtc } from '@jetblack/date-tz'
const date = tzUtc.makeDate(2000, 0, 1, 12, 15, 30, 123)
console.log(tzUtc.minutes(date))
// returns 15
The date.
The minute of the day.
The month index for the given date where 0 is January.
import { tzUtc } from '@jetblack/date-tz'
const date = tzUtc.makeDate(2000, 1, 1)
console.log(tzUtc.month(date))
// returns 1
The date.
The month of the date where 1 is January.
The signed offset in minutes from UTC for the given date.
The date.
The second of the day for a given date.
import { tzUtc } from '@jetblack/date-tz'
const date = tzUtc.makeDate(2000, 0, 1, 12, 15, 30, 123)
console.log(tzUtc.seconds(date))
// returns 30
The date.
The second of the day.
The ISO 8601 date string representation for a given date.
The date.
The ISO date string.
The day of the week for the given date where 0 is Sunday.
import { tzUtc } from '@jetblack/date-tz'
const date = tzUtc.makeDate(2000, 0, 1)
console.log(tzUtc.weekday(date))
// returns 6
The date.
The day of the week where 0 is Sunday.
The year for the date.
import { tzUtc } from '@jetblack/date-tz'
const date = tzUtc.makeDate(2000, 0, 1)
console.log(tzUtc.year(date))
// returns 2000
The date.
The year.
Generated using TypeDoc
The base class for timezones.
Two timezones are provided by default: tzLocal and tzUtc. There is also a class IANATimezone which can be used with the time zone database maintained by IANA. All timezone sensitive operations take a timezone as an optional parameter which defaults to tzLocal.
There is a tutorial here.
The timezone object provides accessors for the common properties of a date such as {@link Timezone['year']}. Here is an example of using the year.
There are two complimentary methods used for date construction: makeDate and dateParts. These are used by the library functions to efficiently deconstruct and construct dates for performing calculations.
There are two functions specific to timezones: isDaylightSavings and toISOString. The JavaScript built in Date.toISOString is only aware of the UTC timezone. This method provides support for any defined timezone.