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
This commit is contained in:
Miklós András Danka
2019-05-28 11:59:45 -07:00
committed by Sheetal Nandi
parent b22b47cf53
commit 6cda797334
2 changed files with 13 additions and 2 deletions
+5 -1
View File
@@ -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 <https://github.com/colbydehart>
// Hyeonseok Yang <https://github.com/FourwingsY>
@@ -7,6 +7,7 @@
// Pietro Vismara <https://github.com/pietrovismara>
// Janeene Beeforth <https://github.com/dawnmist>
// Jason Yu <https://github.com/ycmjason>
// Miklos Danka <https://github.com/mdanka>
// 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;
+8 -1
View File
@@ -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;
}