@terascope/utils / dates
dates
Type Aliases
AdjustDateArgs
AdjustDateArgs:
object
|object
Source
packages/utils/src/dates.ts:724
Variables
getDurationFunc
const
getDurationFunc:object
Type declaration
ISOWeekYears()
ISOWeekYears: (
laterDate
,earlierDate
,options
?) =>number
=differenceInISOWeekYears
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInISOWeekYearsOptions | The options |
Returns
number
businessDays()
businessDays: (
laterDate
,earlierDate
,options
?) =>number
=differenceInBusinessDays
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInBusinessDaysOptions | An object with options |
Returns
number
calendarDays()
calendarDays: (
laterDate
,earlierDate
,options
?) =>number
=differenceInCalendarDays
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInCalendarDaysOptions | The options object |
Returns
number
calendarISOWeekYears()
calendarISOWeekYears: (
laterDate
,earlierDate
,options
?) =>number
=differenceInCalendarISOWeekYears
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInCalendarISOWeekYearsOptions | An object with options |
Returns
number
calendarMonths()
calendarMonths: (
laterDate
,earlierDate
,options
?) =>number
=differenceInCalendarMonths
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInCalendarMonthsOptions | An object with options |
Returns
number
calendarQuarters()
calendarQuarters: (
laterDate
,earlierDate
,options
?) =>number
=differenceInCalendarQuarters
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInCalendarQuartersOptions | An object with options |
Returns
number
calendarWeeks()
calendarWeeks: (
laterDate
,earlierDate
,options
?) =>number
=differenceInCalendarISOWeeks
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInCalendarISOWeeksOptions | An object with options |
Returns
number
calendarYears()
calendarYears: (
laterDate
,earlierDate
,options
?) =>number
=differenceInCalendarYears
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInCalendarYearsOptions | An object with options |
Returns
number
days()
days: (
laterDate
,earlierDate
,options
?) =>number
=differenceInDays
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInDaysOptions | An object with options |
Returns
number
hours()
hours: (
laterDate
,earlierDate
,options
?) =>number
=differenceInHours
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInHoursOptions | An object with options. |
Returns
number
milliseconds()
milliseconds: (
laterDate
,earlierDate
) =>number
=differenceInMilliseconds
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
Returns
number
minutes()
minutes: (
dateLeft
,dateRight
,options
?) =>number
=differenceInMinutes
Parameters
Parameter | Type | Description |
---|---|---|
dateLeft | string | number | Date | The later date |
dateRight | string | number | Date | The earlier date |
options ? | DifferenceInMinutesOptions | An object with options. |
Returns
number
months()
months: (
laterDate
,earlierDate
,options
?) =>number
=differenceInMonths
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInMonthsOptions | An object with options |
Returns
number
quarters()
quarters: (
laterDate
,earlierDate
,options
?) =>number
=differenceInQuarters
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInQuartersOptions | An object with options. |
Returns
number
seconds()
seconds: (
laterDate
,earlierDate
,options
?) =>number
=differenceInSeconds
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInSecondsOptions | An object with options. |
Returns
number
weeks()
weeks: (
laterDate
,earlierDate
,options
?) =>number
=differenceInWeeks
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInWeeksOptions | An object with options |
Returns
number
years()
years: (
laterDate
,earlierDate
,options
?) =>number
=differenceInYears
Parameters
Parameter | Type | Description |
---|---|---|
laterDate | string | number | Date | The later date |
earlierDate | string | number | Date | The earlier date |
options ? | DifferenceInYearsOptions | An object with options |
Returns
number
Source
packages/utils/src/dates.ts:553
timezoneOffset
const
timezoneOffset:number
Source
packages/utils/src/dates.ts:53
Functions
addToDate()
addToDate(
input
,args
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
args | AdjustDateArgs |
Returns
number
Source
packages/utils/src/dates.ts:737
addToDateFP()
addToDateFP(
args
): (input
) =>number
Parameters
Parameter | Type |
---|---|
args | AdjustDateArgs |
Returns
Function
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:747
formatDateValue()
formatDateValue(
value
,format
):string
|number
Format the parsed date value
Parameters
Parameter | Type |
---|---|
value | number | Date | DateTuple |
format | undefined | string |
Returns
string
| number
Source
packages/utils/src/dates.ts:523
getDate()
getDate(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:955
getHours()
getHours(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:945
getMilliseconds()
getMilliseconds(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:922
getMinutes()
getMinutes(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:935
getMonth()
getMonth(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:964
getSeconds()
getSeconds(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:926
getTime()
getTime(
val
?):number
|false
Ensure unix time
Parameters
Parameter | Type |
---|---|
val ? | DateInputTypes |
Returns
number
| false
Source
packages/utils/src/dates.ts:248
getTimeBetween()
getTimeBetween(
input
,args
):string
|number
Parameters
Parameter | Type |
---|---|
input | unknown |
args | GetTimeBetweenArgs |
Returns
string
| number
Source
packages/utils/src/dates.ts:573
getTimeBetweenFP()
getTimeBetweenFP(
args
): (input
) =>string
|number
A functional version of getTimeBetween
Parameters
Parameter | Type |
---|---|
args | GetTimeBetweenArgs |
Returns
Function
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
string
| number
Source
packages/utils/src/dates.ts:611
getTimezoneOffset()
getTimezoneOffset(
input
,timezone
):number
Given a date and timezone, it will return the offset from UTC in minutes. This is more accurate than timezoneToOffset as it can better account for day lights saving time
Parameters
Parameter | Type |
---|---|
input | unknown |
timezone | string |
Returns
number
Source
packages/utils/src/dates.ts:820
getTimezoneOffsetFP()
getTimezoneOffsetFP(
timezone
): (input
) =>number
Given a timezone, it will return a function that will take in dates that will be converted the offset in minutes. This is more accurate than timezoneToOffset as it can better account for day lights saving time
Parameters
Parameter | Type |
---|---|
timezone | string |
Returns
Function
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:834
getUTCDate()
getUTCDate(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:950
getUTCHours()
getUTCHours(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:940
getUTCMinutes()
getUTCMinutes(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:930
getUTCMonth()
getUTCMonth(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:960
getUTCYear()
getUTCYear(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:968
getUnixTime()
getUnixTime(
val
?):number
|false
Parameters
Parameter | Type |
---|---|
val ? | DateInputTypes |
Returns
number
| false
Source
packages/utils/src/dates.ts:255
getValidDate()
getValidDate(
val
,relativeNow
):Date
|false
Coerces value into a valid date, returns false if it is invalid. Has added support for converting from date math (i.e. now+1h, now-1m, now+2d/y, 2021-01-01||+2d)
Parameters
Parameter | Type |
---|---|
val | unknown |
relativeNow | Date |
Returns
Date
| false
Source
packages/utils/src/dates.ts:121
getValidDateOrNumberOrThrow()
getValidDateOrNumberOrThrow(
val
):Date
|number
Returns a valid date or throws, {@see getValidDate}
Parameters
Parameter | Type |
---|---|
val | unknown |
Returns
Date
| number
Source
packages/utils/src/dates.ts:231
getValidDateOrThrow()
getValidDateOrThrow(
val
):Date
Returns a valid date or throws, {@see getValidDate}
Parameters
Parameter | Type |
---|---|
val | unknown |
Returns
Date
Source
packages/utils/src/dates.ts:158
getValidDateWithTimezone()
getValidDateWithTimezone(
val
,getUTC
):Date
|false
Returns a valid date with the timezone applied {@see getValidDate}
Parameters
Parameter | Type | Default value |
---|---|---|
val | unknown | undefined |
getUTC | boolean | false |
Returns
Date
| false
Source
packages/utils/src/dates.ts:220
getValidDateWithTimezoneOrThrow()
getValidDateWithTimezoneOrThrow(
val
,getUTC
):Date
Returns a valid date with the timezone applied or throws{@see getValidDate}
Parameters
Parameter | Type | Default value |
---|---|---|
val | unknown | undefined |
getUTC | boolean | false |
Returns
Date
Source
packages/utils/src/dates.ts:209
getYear()
getYear(
input
):number
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
number
Source
packages/utils/src/dates.ts:972
isAfter()
isAfter(
input
,date
):boolean
Parameters
Parameter | Type |
---|---|
input | unknown |
date | DateInputTypes |
Returns
boolean
Source
packages/utils/src/dates.ts:780
isBefore()
isBefore(
input
,date
):boolean
Parameters
Parameter | Type |
---|---|
input | unknown |
date | DateInputTypes |
Returns
boolean
Source
packages/utils/src/dates.ts:769
isBetween()
isBetween(
input
,args
):boolean
Parameters
Parameter | Type |
---|---|
input | unknown |
args | object |
args.end | DateInputTypes |
args.start | DateInputTypes |
Returns
boolean
Source
packages/utils/src/dates.ts:791
isDateTuple()
isDateTuple(
input
):input is DateTuple
Verify if an input is a Date Tuple
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
input is DateTuple
Source
packages/utils/src/dates.ts:363
isFriday()
isFriday(
input
):boolean
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
boolean
Source
packages/utils/src/dates.ts:652
isFuture()
isFuture(
input
):boolean
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
boolean
Source
packages/utils/src/dates.ts:682
isISO8601()
isISO8601(
input
):input is string
Checks to see if an input is a ISO 8601 date
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
input is string
Source
packages/utils/src/dates.ts:283
isLeapYear()
isLeapYear(
input
):boolean
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
boolean
Source
packages/utils/src/dates.ts:696
isMonday()
isMonday(
input
):boolean