From 6cda797334a3d0bd37539844258c82e1fbbfb979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Andr=C3=A1s=20Danka?= Date: Tue, 28 May 2019 20:59:45 +0200 Subject: [PATCH] Update type definitions with changes from Luxon 1.13 to 1.15 (#35760) * Added changes from Luxon 1.14 and 1.15 * Removed patch version from header * Added new definition author --- types/luxon/index.d.ts | 6 +++++- types/luxon/luxon-tests.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/types/luxon/index.d.ts b/types/luxon/index.d.ts index 4ec7fa4730..1aa116a2ef 100644 --- a/types/luxon/index.d.ts +++ b/types/luxon/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for luxon 1.13 +// Type definitions for luxon 1.15 // Project: https://github.com/moment/luxon#readme // Definitions by: Colby DeHart // Hyeonseok Yang @@ -7,6 +7,7 @@ // Pietro Vismara // Janeene Beeforth // Jason Yu +// Miklos Danka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -496,8 +497,11 @@ export interface ZoneOffsetOptions { localeCode?: string; } +export type ZoneOffsetFormat = 'narrow' | 'short' | 'techie'; + export class Zone { offsetName(ts: number, options?: ZoneOffsetOptions): string; + formatOffset(ts: number, format: ZoneOffsetFormat): string; isValid: boolean; name: string; type: string; diff --git a/types/luxon/luxon-tests.ts b/types/luxon/luxon-tests.ts index 69c5bb010d..2085215abf 100644 --- a/types/luxon/luxon-tests.ts +++ b/types/luxon/luxon-tests.ts @@ -10,6 +10,7 @@ import { IANAZone, Zone, ZoneOffsetOptions, + ZoneOffsetFormat, } from 'luxon'; /* DateTime */ @@ -26,10 +27,13 @@ const fromObject = DateTime.fromObject({ }); const ianaZone = new IANAZone('America/Los_Angeles'); -IANAZone.create("Europe/London"); +const testIanaZone = IANAZone.create("Europe/London"); IANAZone.isValidSpecifier("Europe/London"); IANAZone.isValidZone("Europe/London"); IANAZone.resetCache(); +testIanaZone.formatOffset(dt.toMillis(), 'narrow'); // => +1 +testIanaZone.formatOffset(dt.toMillis(), 'short'); // => +01:00 +testIanaZone.formatOffset(dt.toMillis(), 'techie'); // => +0100 const ianaZoneTest = DateTime.fromObject({ zone: ianaZone, }); @@ -328,6 +332,9 @@ class SampleZone extends Zone { offsetName(ts: number, options?: ZoneOffsetOptions) { return 'SampleZone'; } + formatOffset(ts: number, format: ZoneOffsetFormat) { + return '+6'; + } equals(other: Zone) { return other.name === this.name; }