diff --git a/docs/classes/Calendar.html b/docs/classes/Calendar.html index 3efe8d8..7522418 100644 --- a/docs/classes/Calendar.html +++ b/docs/classes/Calendar.html @@ -10,13 +10,13 @@
This is how the WeekendCalendar is defined.
import { Calendar, Timezone } from '@jetblack/date'
export class WeekendCalendar extends Calendar {
#weekends: number[]
constructor(name: string = 'WeekendCalendar', weekends: number[] = [0, 6]) {
super(name)
this.#weekends = weekends
}
isWeekend(date: Date, tz: Timezone): boolean {
const dayOfWeek = tz.weekday(date)
return this.#weekends.some(x => x === dayOfWeek)
}
isHoliday(date: Date, tz: Timezone): boolean {
return this.isWeekend(date)
}
}
-Construct a calendar.
The calendar name.
-Get the calendar name.
-Check if the date is a holiday.
The date to check.
diff --git a/docs/classes/Duration.html b/docs/classes/Duration.html index d2cbfcd..e7d3795 100644 --- a/docs/classes/Duration.html +++ b/docs/classes/Duration.html @@ -6,7 +6,7 @@Note that durations may be negative.
import { Duration } from '@jetblack/date'
const duration = new Duration('-P1D')
const d1 = addDuration(new Date('2000-01-01T00:00:00Z'), duration)
console.log(d1)
// Fri Dec 31 1999 00:00:00 GMT+0000 (Greenwich Mean Time)
-Constructs a duration.
The resulting duration will be simplified. For example 12 months will become 1 year and 0 months.
@@ -33,7 +33,7 @@The minutes.
The seconds.
-Constructs a year from the string representation, the number of seconds, or another duration object.
The resulting duration will be simplified. For example 12 months will @@ -49,43 +49,43 @@
The duration as a string, number, or duration.
-Gets the days.
-Sets the days.
If the value is greater than or equal to 7 the duration is simplified.
-Gets the hours.
-Sets the hours.
If the value is greater than or equal to 24 the duration is simplified.
-Gets the minutes.
-Sets the minutes.
If the value is greater than or equal to 60 the duration is simplified.
-Gets the months.
-Sets the months.
If the value is greater than or equal to 12 the duration is simplified.
-Gets the seconds.
-Sets the seconds.
If the value is greater than or equal to 60 the value is simplified.
-Gets the weeks.
-Sets the weeks.
-Gets the years.
-Sets the years.
-Creates a string representation of the duration.
An ISO 8601 duration.
-The number of milliseconds of the duration assuming a year has 360 days and a month has 30 days.
Note that this is not idempotent. As the actual number of days in a year diff --git a/docs/classes/HolidayCalendar.html b/docs/classes/HolidayCalendar.html index 535f844..b94179e 100644 --- a/docs/classes/HolidayCalendar.html +++ b/docs/classes/HolidayCalendar.html @@ -3,7 +3,7 @@
The following constructs a holiday calendar for the US in 2020.
import { HolidayCalendar } from '@jetblack/date'
const calUS = new HolidayCalendar(
'US',
[0, 6], // Saturday and Sunday are always holidays.
[
new Date('2020-01-01'), // Wed: New Year's Day
new Date('2020-01-20'), // Mon: Martin Luther King Jr. Day
new Date('2020-05-25'), // Mon: Memorial Day
new Date('2020-07-03'), // Fri: Independence Day
new Date('2020-09-07'), // Mon: Labor Day
new Date('2020-11-11'), // Wed: Veterans Day
new Date('2020-11-26'), // Thu: Thanksgiving
new Date('2020-12-25') // Fri: Christmas Day
]
)
-Construct a holiday calendar.
The calendar name.
@@ -11,11 +11,11 @@An array of weekdays which are always holidays.
An array of dates which are holidays.
-Get the calendar name.
-Check if the date is a holiday.
-Check if the date is a weekend.
The date.
diff --git a/docs/classes/IANATimezone.html b/docs/classes/IANATimezone.html index f576970..f34d612 100644 --- a/docs/classes/IANATimezone.html +++ b/docs/classes/IANATimezone.html @@ -3,15 +3,15 @@This example gets the data from the internet.
import { IANATimezone, minDataToTimezoneOffset } from '@jetblack/date'
const timezoneName = 'Europe/Brussels'
fetch(`https://cdn.jsdelivr.net/npm/@jetblack/tzdata/dist/latest/${timezoneName}.min.json`)
.then(response => response.json())
.then(data => {
const zoneData = data.map(minDataToTimezoneOffset)
const tz = new IANATimezone(timeZoneName, zoneData)
const newYearsDay = tz.makeDate(2000, 0, 1)
// returns "2000-01-01T01:00:00Z"
})
.catch(error => console.error(error))
}
-Construct a custom timezone.
The timezone name.
The timezone offsets
-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 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,
monthIndex,
day,
weekday,
hours,
minutes,
seconds,
milliseconds
} = tz.dateParts(date)
-The day of the month for the given date.
import { tzUtc } from '@jetblack/date'
const date = tzUtc.makeDate(2000, 0, 1)
console.log(tzUtc.day(date))
// returns 1
-The hour of the day for the given date.
import { tzUtc } from '@jetblack/date'
const date = tzUtc.makeDate(2000, 0, 1, 12, 15, 30, 123)
console.log(tzUtc.hours(date))
// returns 12
-Find if the date was subject to daylight savings time.
-Create a date from its component parts.
-The millisecond of the day for a given date.
import { tzUtc } from '@jetblack/date'
const date = tzUtc.makeDate(2000, 0, 1, 12, 15, 30, 123)
console.log(tzUtc.milliseconds(date))
// returns 123
-The minute of the day for the given date.
import { tzUtc } from '@jetblack/date'
const date = tzUtc.makeDate(2000, 0, 1, 12, 15, 30, 123)
console.log(tzUtc.minutes(date))
// returns 15
-The month index for the given date where 0 is January.
import { tzUtc } from '@jetblack/date'
const date = tzUtc.makeDate(2000, 0, 1)
console.log(tzUtc.monthIndex(date))
// returns 0
-The signed offset in minutes from UTC for the given date.
-The second of the day for a given date.
import { tzUtc } from '@jetblack/date'
const date = tzUtc.makeDate(2000, 0, 1, 12, 15, 30, 123)
console.log(tzUtc.seconds(date))
// returns 30
-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'
const date = tzUtc.makeDate(2000, 0, 1)
console.log(tzUtc.weekday(date))
// returns 6
-The year for the date.
import { tzUtc } from '@jetblack/date'
const date = tzUtc.makeDate(2000, 0, 1)
console.log(tzUtc.year(date))
// returns 2000
diff --git a/docs/classes/LocaleInfo.html b/docs/classes/LocaleInfo.html
index 70f59e4..a58511f 100644
--- a/docs/classes/LocaleInfo.html
+++ b/docs/classes/LocaleInfo.html
@@ -1,14 +1,14 @@
A class holding information for locales.
The class attempts to load locale info from the browser.
-The day period names
-the plurals for days from one to thirty one
-The locale
-The month names
-The weekday names
Generated using TypeDoc
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 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.
@@ -42,26 +42,26 @@The date.
The date parts.
-The day of the month for the given date.
import { tzUtc } from '@jetblack/date'
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'
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.
@@ -78,51 +78,51 @@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'
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'
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'
const date = tzUtc.makeDate(2000, 0, 1)
console.log(tzUtc.monthIndex(date))
// returns 0
The date.
The month index of the date where 0 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'
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'
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'
const date = tzUtc.makeDate(2000, 0, 1)
console.log(tzUtc.year(date))
// returns 2000
diff --git a/docs/classes/WeekendCalendar.html b/docs/classes/WeekendCalendar.html
index 8cc9f40..5b01ba0 100644
--- a/docs/classes/WeekendCalendar.html
+++ b/docs/classes/WeekendCalendar.html
@@ -1,21 +1,21 @@
A calendar where specific days of the week are considered holidays.
-Construct a weekend calendar.
An optional calendar name.
An optional array of week days. Defaults to [0, 6]
for Saturday and Sunday.
Get the calendar name.
-Check if the date is a holiday.
The date to check.
An optional timezone. Defaults to the local timezone.
True if the date is a holiday, otherwise false.
-Check if the date is a weekend.
The date.
diff --git a/docs/enums/BusinessDayConvention.html b/docs/enums/BusinessDayConvention.html index 030cc04..fade845 100644 --- a/docs/enums/BusinessDayConvention.html +++ b/docs/enums/BusinessDayConvention.html @@ -5,16 +5,16 @@ nearest non-holiday.The modified rules determine what to do when the adjustment is at the end of the month.
-Adjust to the nearest business day after the current day
-Adjust to the nearest business day after the current day withing the month; otherwise adjust following
-Adjust to the nearest business day after the current day withing the month; otherwise adjust preceding
-Adjust to the nearest business day
-No adjustment
-Adjust to the nearest business day before the current day
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc