From ad735eb279aeaaa6eef7a6d7d9318f56425988dd Mon Sep 17 00:00:00 2001 From: Carson Full Date: Tue, 12 Jun 2018 14:00:07 -0500 Subject: [PATCH 1/3] [luxon] Changes for 1.2 --- types/luxon/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/luxon/index.d.ts b/types/luxon/index.d.ts index d90ba90b13..544be249ee 100644 --- a/types/luxon/index.d.ts +++ b/types/luxon/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for luxon 0.5 +// Type definitions for luxon 1.2 // Project: https://github.com/moment/luxon#readme // Definitions by: Colby DeHart // Hyeonseok Yang @@ -207,6 +207,7 @@ declare module 'luxon' { toLocal(): DateTime; toLocaleParts(options?: DateTimeFormatOptions): any[]; toLocaleString(options?: DateTimeFormatOptions): string; + toMillis(): number; toObject(options?: { includeConfig?: boolean }): DateObject; toRFC2822(): string; toSQL(options?: Object): string; From 9d7b8fcf774749276ffb35fc752ae7054eaa27f7 Mon Sep 17 00:00:00 2001 From: Carson Full Date: Tue, 12 Jun 2018 15:01:48 -0500 Subject: [PATCH 2/3] [luxon] Tighten allowed unit values --- types/luxon/index.d.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/types/luxon/index.d.ts b/types/luxon/index.d.ts index 544be249ee..6fd4f200db 100644 --- a/types/luxon/index.d.ts +++ b/types/luxon/index.d.ts @@ -180,14 +180,14 @@ declare module 'luxon' { zoneName: string; diff( other: DateTime, - unit?: string | string[], + unit?: DurationUnit | DurationUnit[], options?: DiffOptions ): Duration; - diffNow(unit?: string | string[], options?: DiffOptions): Duration; - endOf(unit: string): DateTime; + diffNow(unit?: DurationUnit | DurationUnit[], options?: DiffOptions): Duration; + endOf(unit: DurationUnit): DateTime; equals(other: DateTime): boolean; - get(unit: string): number; - hasSame(other: DateTime, unit: string): boolean; + get(unit: keyof DateTime): number; + hasSame(other: DateTime, unit: DurationUnit): boolean; minus(duration: Duration | number | DurationObject): DateTime; plus(duration: Duration | number | DurationObject): DateTime; reconfigure(properties: LocaleOptions): DateTime; @@ -195,7 +195,7 @@ declare module 'luxon' { set(values: DateObjectUnits): DateTime; setLocale(locale: any): DateTime; setZone(zone: string | Zone, options?: ZoneOptions): DateTime; - startOf(unit: string): DateTime; + startOf(unit: DurationUnit): DateTime; toFormat(format: string, options?: ToFormatOptions): string; toHTTP(): string; toISO(options?: ISOTimeOptions): string; @@ -238,6 +238,9 @@ declare module 'luxon' { type DurationObject = DurationObjectUnits & DurationOptions; + type DurationUnit = 'year' | 'years' | 'quarter' | 'quarters' | 'month' | 'months' | 'week' | 'weeks' | 'day' | 'days' + | 'hour' | 'hours' | 'minute' | 'minutes' | 'second' | 'seconds' | 'millisecond' | 'milliseconds'; + class Duration { static fromISO(text: string, options?: DurationOptions): Duration; static fromMillis( @@ -261,16 +264,16 @@ declare module 'luxon' { seconds: number; weeks: number; years: number; - as(unit: string): number; + as(unit: DurationUnit): number; equals(other: Duration): boolean; - get(unit: string): number; + get(unit: DurationUnit): number; minus(duration: Duration | number | DurationObject): Duration; negate(): Duration; normalize(): Duration; plus(duration: Duration | number | DurationObject): Duration; reconfigure(objectPattern: DurationOptions): Duration; set(values: DurationObjectUnits): Duration; - shiftTo(...units: string[]): Duration; + shiftTo(...units: DurationUnit[]): Duration; toFormat(format: string, options?: ToFormatOptions): string; toISO(): string; toJSON(): string; @@ -341,23 +344,23 @@ declare module 'luxon' { abutsEnd(other: Interval): boolean; abutsStart(other: Interval): boolean; contains(dateTime: DateTime): boolean; - count(unit?: string): number; + count(unit?: DurationUnit): number; difference(...intervals: Interval[]): Interval[]; divideEqually(numberOfParts?: number): Interval[]; engulfs(other: Interval): boolean; equals(other: Interval): boolean; - hasSame(unit: string): boolean; + hasSame(unit: DurationUnit): boolean; intersection(other: Interval): Interval; isAfter(dateTime: DateTime): boolean; isBefore(dateTime: DateTime): boolean; isEmpty(): boolean; - length(unit?: string): number; + length(unit?: DurationUnit): number; overlaps(other: Interval): boolean; set(values: IntervalObject): Interval; splitAt(...dateTimes: DateTime[]): Interval[]; splitBy(duration: Duration | DurationObject | number): Interval[]; toDuration( - unit: string | string[], + unit: DurationUnit | DurationUnit[], options?: DiffOptions ): Duration; toFormat( From 8686685640d351fcd49784d46ee335092692f703 Mon Sep 17 00:00:00 2001 From: Carson Full Date: Tue, 12 Jun 2018 15:09:26 -0500 Subject: [PATCH 3/3] [luxon] Added DateTime.toBSON() and Duration.valueOf() --- types/luxon/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/luxon/index.d.ts b/types/luxon/index.d.ts index 6fd4f200db..bcf43d0dac 100644 --- a/types/luxon/index.d.ts +++ b/types/luxon/index.d.ts @@ -196,6 +196,7 @@ declare module 'luxon' { setLocale(locale: any): DateTime; setZone(zone: string | Zone, options?: ZoneOptions): DateTime; startOf(unit: DurationUnit): DateTime; + toBSON(): Date; toFormat(format: string, options?: ToFormatOptions): string; toHTTP(): string; toISO(options?: ISOTimeOptions): string; @@ -281,6 +282,7 @@ declare module 'luxon' { includeConfig?: boolean; }): DurationObject; toString(): string; + valueOf(): number; } type EraLength = 'short' | 'long';