11// Type definitions for luxon 0.2
22// Project: https://github.com/moment/luxon#readme
33// Definitions by: Colby DeHart <https://github.com/colbydehart>
4+ // Hyeonseok Yang <https://github.com/FourwingsY>
45// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6+ // TypeScript Version: 2.2
57
68declare module 'luxon' {
79 namespace luxon {
8- type DateTimeFormat = any ;
10+ type DateTimeFormatOptions = Intl . DateTimeFormatOptions ;
11+
912 type ZoneOptions = {
1013 keepCalendarTime ?: boolean ;
1114 } ;
1215
13- type ToFormatOptions = {
14- round : boolean ;
16+ type ToFormatOptions = DateTimeFormatOptions & {
17+ round ? : boolean ;
1518 } ;
1619
1720 type ISOTimeOptions = {
1821 suppressMilliseconds ?: boolean ;
19- supressSeconds ?: boolean ;
22+ suppressSeconds ?: boolean ;
23+ includeOffset ?: boolean ;
2024 } ;
2125
22- type DateTimeOptions = {
23- zone ?: string | Zone ;
24- setZone ?: boolean ;
26+ type LocaleOptions = {
2527 locale ?: string ;
2628 outputCalendar ?: string ;
2729 numberingSystem ?: string ;
2830 } ;
2931
30- type DateTimeJSOptions = {
32+ type DateTimeOptions = LocaleOptions & {
33+ zone ?: string | Zone ;
34+ setZone ?: boolean ;
35+ } ;
36+
37+ type DateTimeJSOptions = LocaleOptions & {
3138 zone ?: string | Zone ;
3239 } ;
3340
3441 type DateObjectUnits = {
3542 year ?: number ;
43+ month ?: number ;
3644 day ?: number ;
3745 ordinal ?: number ;
3846 weekYear ?: number ;
@@ -44,38 +52,35 @@ declare module 'luxon' {
4452 millisecond ?: number ;
4553 } ;
4654
47- type DateObject = DateObjectUnits & {
55+ type DateObject = DateObjectUnits & LocaleOptions & {
4856 zone ?: string | Zone ;
49- locale ?: string ;
50- outputCalendar ?: string ;
51- numberingSystem ?: string ;
5257 } ;
5358
5459 type DiffOptions = {
5560 conversionAccuracy ?: string ;
5661 } ;
5762
5863 class DateTime {
59- static DATETIME_FULL : DateTimeFormat ;
60- static DATETIME_FULL_WITH_SECONDS : DateTimeFormat ;
61- static DATEIME_HUGE : DateTimeFormat ;
62- static DATEIME_HUGE_WITH_SECONDS : DateTimeFormat ;
63- static DATETIME_MED : DateTimeFormat ;
64- static DATETIME_MED_WITH_SECONDS : DateTimeFormat ;
65- static DATETIME_SHORT : DateTimeFormat ;
66- static DATETIME_SHORT_WITH_SECONDS : DateTimeFormat ;
67- static DATE_FULL : DateTimeFormat ;
68- static DATE_HUGE : DateTimeFormat ;
69- static DATE_MED : DateTimeFormat ;
70- static DATE_SHORT : DateTimeFormat ;
71- static TIME_24_SIMPLE : DateTimeFormat ;
72- static TIME_24_WITH_LONG_OFFSET : DateTimeFormat ;
73- static TIME_24_WITH_SECONDS : DateTimeFormat ;
74- static TIME_24_WITH_SHORT_OFFSET : DateTimeFormat ;
75- static TIME_SIMPLE : DateTimeFormat ;
76- static TIME_WITH_LONG_OFFSET : DateTimeFormat ;
77- static TIME_WITH_SECONDS : DateTimeFormat ;
78- static TIME_WITH_SHORT_OFFSET : DateTimeFormat ;
64+ static DATETIME_FULL : DateTimeFormatOptions ;
65+ static DATETIME_FULL_WITH_SECONDS : DateTimeFormatOptions ;
66+ static DATEIME_HUGE : DateTimeFormatOptions ;
67+ static DATEIME_HUGE_WITH_SECONDS : DateTimeFormatOptions ;
68+ static DATETIME_MED : DateTimeFormatOptions ;
69+ static DATETIME_MED_WITH_SECONDS : DateTimeFormatOptions ;
70+ static DATETIME_SHORT : DateTimeFormatOptions ;
71+ static DATETIME_SHORT_WITH_SECONDS : DateTimeFormatOptions ;
72+ static DATE_FULL : DateTimeFormatOptions ;
73+ static DATE_HUGE : DateTimeFormatOptions ;
74+ static DATE_MED : DateTimeFormatOptions ;
75+ static DATE_SHORT : DateTimeFormatOptions ;
76+ static TIME_24_SIMPLE : DateTimeFormatOptions ;
77+ static TIME_24_WITH_LONG_OFFSET : DateTimeFormatOptions ;
78+ static TIME_24_WITH_SECONDS : DateTimeFormatOptions ;
79+ static TIME_24_WITH_SHORT_OFFSET : DateTimeFormatOptions ;
80+ static TIME_SIMPLE : DateTimeFormatOptions ;
81+ static TIME_WITH_LONG_OFFSET : DateTimeFormatOptions ;
82+ static TIME_WITH_SECONDS : DateTimeFormatOptions ;
83+ static TIME_WITH_SHORT_OFFSET : DateTimeFormatOptions ;
7984 static fromHTTP ( text : string , options ?: DateTimeOptions ) : DateTime ;
8085 static fromISO ( text : string , options ?: DateTimeOptions ) : DateTime ;
8186 static fromJSDate (
@@ -98,7 +103,7 @@ declare module 'luxon' {
98103 text : string ,
99104 format : string ,
100105 options ?: DateTimeOptions
101- ) : Object ;
106+ ) : object ;
102107 static invalid ( reason : any ) : DateTime ;
103108 static local (
104109 year ?: number ,
@@ -110,7 +115,7 @@ declare module 'luxon' {
110115 millisecond ?: number
111116 ) : DateTime ;
112117 static max ( ...dateTimes : DateTime [ ] ) : DateTime | undefined ;
113- static min ( ...dateTimes : DateTime [ ] ) : DateTime ;
118+ static min ( ...dateTimes : DateTime [ ] ) : DateTime | undefined ;
114119 static utc (
115120 year ?: number ,
116121 month ?: number ,
@@ -138,12 +143,12 @@ declare module 'luxon' {
138143 offset : number ;
139144 offsetNameLong : string ;
140145 offsetNameShort : string ;
141- ordinal : number | DateTime ;
146+ ordinal : number ;
142147 outputCalendar : string ;
143148 second : number ;
144149 weekNumber : number ;
145150 weekYear : number ;
146- weekday : string ;
151+ weekday : number ;
147152 weekdayLong : string ;
148153 weekdayShort : string ;
149154 year : number ;
@@ -158,27 +163,25 @@ declare module 'luxon' {
158163 equals ( other : DateTime ) : boolean ;
159164 get ( unit : string ) : number ;
160165 hasSame ( other : DateTime , unit : string ) : boolean ;
161- minus ( duration : Duration ) : DateTime ;
162- minus ( milliseconds : number ) : DateTime ;
163- minus ( durationObject : DurationObject ) : DateTime ;
164- plus ( duration : Duration | number | Object ) : DateTime ;
165- reconfigure ( properties : Object ) : DateTime ;
166- resolvedLocaleOptions ( options ?: Object ) : Object ;
166+ minus ( duration : Duration | number | DurationObject ) : DateTime ;
167+ plus ( duration : Duration | number | DurationObject ) : DateTime ;
168+ reconfigure ( properties : LocaleOptions ) : DateTime ;
169+ resolvedLocaleOpts ( options ?: ToFormatOptions ) : LocaleOptions ;
167170 set ( values : DateObjectUnits ) : DateTime ;
168171 setLocale ( locale : any ) : DateTime ;
169172 setZone ( zone : string | Zone , options ?: ZoneOptions ) : DateTime ;
170173 startOf ( unit : string ) : DateTime ;
171174 toFormat ( format : string , options ?: ToFormatOptions ) : string ;
172175 toHTTP ( ) : string ;
173- toISO ( options ?: Object ) : string ;
176+ toISO ( options ?: ISOTimeOptions ) : string ;
174177 toISODate ( ) : string ;
175178 toISOTime ( options ?: ISOTimeOptions ) : string ;
176179 toISOWeekDate ( ) : string ;
177180 toJSDate ( ) : Date ;
178181 toJSON ( ) : string ;
179182 toLocal ( ) : DateTime ;
180- toLocaleParts ( options ?: Object ) : any [ ] ;
181- toLocaleString ( options ?: DateTimeFormat ) : string ;
183+ toLocaleParts ( options ?: DateTimeFormatOptions ) : any [ ] ;
184+ toLocaleString ( options ?: DateTimeFormatOptions ) : string ;
182185 toObject ( options ?: { includeConfig ?: boolean } ) : DateObject ;
183186 toRFC2822 ( ) : string ;
184187 toSQL ( options ?: Object ) : string ;
@@ -196,7 +199,7 @@ declare module 'luxon' {
196199 conversionAccuracy ?: string ;
197200 } ;
198201
199- type DurationObject = {
202+ type DurationObjectUnits = {
200203 years ?: number ;
201204 months ?: number ;
202205 weeks ?: number ;
@@ -207,14 +210,16 @@ declare module 'luxon' {
207210 milliseconds ?: number ;
208211 } ;
209212
213+ type DurationObject = DurationObjectUnits & DurationOptions ;
214+
210215 class Duration {
211216 static fromISO ( text : string , options ?: DurationOptions ) : Duration ;
212217 static fromMillis (
213218 count : number ,
214219 options ?: DurationOptions
215220 ) : Duration ;
216221 static fromObject (
217- Object : DurationObject & DurationOptions
222+ Object : DurationObject
218223 ) : Duration ;
219224 static invalid ( reason ?: string ) : Duration ;
220225 days : number ;
@@ -232,24 +237,24 @@ declare module 'luxon' {
232237 as ( unit : string ) : number ;
233238 equals ( other : Duration ) : boolean ;
234239 get ( unit : string ) : number ;
235- minus ( duration : Duration | number | Object ) : Duration ;
240+ minus ( duration : Duration | number | DurationObject ) : Duration ;
236241 negate ( ) : Duration ;
237242 normalize ( ) : Duration ;
238- plus ( duration : Duration | number | Object ) : Duration ;
243+ plus ( duration : Duration | number | DurationObject ) : Duration ;
239244 reconfigure ( objectPattern : DurationOptions ) : Duration ;
240- set ( values : DurationObject ) : Duration ;
245+ set ( values : DurationObjectUnits ) : Duration ;
241246 shiftTo ( ...units : string [ ] ) : Duration ;
242247 toFormat ( format : string , options ?: ToFormatOptions ) : string ;
243248 toISO ( ) : string ;
244249 toJSON ( ) : string ;
245250 toObject ( options ?: {
246251 includeConfig ?: boolean ;
247- } ) : DurationObject & DurationOptions ;
252+ } ) : DurationObject ;
248253 toString ( ) : string ;
249254 }
250255
251256 type EraLength = 'short' | 'long' ;
252- type UnitLength = EraLength & 'numeric' | '2-digit' | 'narrow' ;
257+ type UnitLength = EraLength | 'numeric' | '2-digit' | 'narrow' ;
253258 type UnitOptions = InfoOptions & {
254259 numberingSystem ?: string ;
255260 outputCalendar ?: string ;
@@ -265,19 +270,19 @@ declare module 'luxon' {
265270 timezones : boolean ;
266271 } ;
267272
268- type Info = {
269- eras ( length ?: EraLength , options ?: InfoOptions ) : string [ ] ;
270- features ( ) : Features ;
271- hasDST ( zone : string | Zone ) : boolean ;
272- meridiems ( options ?: InfoOptions ) : string [ ] ;
273- months ( length ?: UnitLength , options ?: UnitOptions ) : string [ ] ;
274- monthsFormat ( length ?: UnitLength , options ?: UnitOptions ) : string [ ] ;
275- weeksdays ( length ?: UnitLength , options ?: UnitOptions ) : string [ ] ;
276- weekdaysFormat (
273+ namespace Info {
274+ function eras ( length ?: EraLength , options ?: InfoOptions ) : string [ ] ;
275+ function features ( ) : Features ;
276+ function hasDST ( zone : string | Zone ) : boolean ;
277+ function meridiems ( options ?: InfoOptions ) : string [ ] ;
278+ function months ( length ?: UnitLength , options ?: UnitOptions ) : string [ ] ;
279+ function monthsFormat ( length ?: UnitLength , options ?: UnitOptions ) : string [ ] ;
280+ function weekdays ( length ?: UnitLength , options ?: UnitOptions ) : string [ ] ;
281+ function weekdaysFormat (
277282 length ?: UnitLength ,
278283 options ?: UnitOptions
279284 ) : string [ ] ;
280- } ;
285+ }
281286
282287 type IntervalObject = {
283288 start : DateTime ;
@@ -333,21 +338,21 @@ declare module 'luxon' {
333338 seperator ?: string ;
334339 }
335340 ) : string ;
336- toISO ( options ?: Object ) : string ;
341+ toISO ( options ?: ISOTimeOptions ) : string ;
337342 toString ( ) : string ;
338343 union ( other : Interval ) : Interval ;
339344 }
340345
341- type Settings = {
342- defaultLocale : string ;
343- defaultNumberingSystem : string ;
344- defaultOutputCalendar : string ;
345- defaultZone : Zone ;
346- defaultZoneName : string ;
347- now : Function ;
348- throwOnInvalid : boolean ;
349- resetCache ( ) : void ;
350- } ;
346+ namespace Settings {
347+ let defaultLocale : string ;
348+ let defaultNumberingSystem : string ;
349+ let defaultOutputCalendar : string ;
350+ const defaultZone : Zone ;
351+ let defaultZoneName : string ;
352+ let throwOnInvalid : boolean ;
353+ let now : ( ) => number ;
354+ function resetCache ( ) : void ;
355+ }
351356
352357 type ZoneOffsetOptions = {
353358 format ?: 'short' | 'long' ;
@@ -361,7 +366,7 @@ declare module 'luxon' {
361366 static type : string ;
362367 static universal : boolean ;
363368 equals ( other : Zone ) : boolean ;
364- static offset ( ts : number ) : number ;
369+ offset ( ts : number ) : number ;
365370 }
366371 }
367372
0 commit comments