-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAasaamDateTime.d.ts
309 lines (270 loc) · 8.05 KB
/
AasaamDateTime.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
import { Moment as MomentGeorgian } from 'moment';
import { Moment as MomentJalaali } from 'moment-jalaali';
// Calendar supported types
type Calendar = 'p' | 'g';
// ISO 639-1 language code
type Language = 'ar' | 'az' | 'bn' | 'de' | 'en' | 'es' | 'fa' | 'fr' | 'hi' | 'id' | 'it' | 'ja' | 'ko' | 'ku' | 'nl' | 'pl' | 'ps' | 'pt' | 'ru' | 'sw' | 'tr' | 'ur' | 'zh';
// ISO 8601 Date time format
type ISOFormatObject = {
c: string,
H: string,
HH: string,
m: string,
mm: string,
s: string,
ss: string,
YYYY: string,
YY: string,
MMMM: string,
MM: string,
M: string,
d: string,
dd: string,
E: string,
EE: string,
EEEE: string,
e: string,
G: string,
GGGG: string,
zzzz: string,
};
type YearItem = {
i: number,
native: string,
locale: string,
selected: boolean,
date: Date,
};
type MonthItem = {
i: number,
native: string,
locale: string,
selected: boolean,
date: Date,
};
type SpecialDay = {
calendar: string,
dayLocale: string,
dayNative: string,
monthName: string,
monthNumber: number,
monthNameNative: string
};
type PreferredCalendars = {
[key: string]: Calendar[]
};
type DateAlternate = {
calendar: Calendar,
dayNative: string,
dayLocale: string,
monthName: string,
monthNameNative: string,
};
type DayEvent = {
th: number,
thLocale: string,
title: string,
};
type DayInMonth = {
date: Date,
dateOnly: Date,
dateStart: Date,
dateEnd: Date,
dayNative: string,
dayLocale: string,
localeDate: string,
alt: DateAlternate[],
weekSeq: number,
weekend: boolean,
selected: boolean,
};
type MonthWeekDays = {
calendar: string,
calendarName: string,
calendarNameAbbr: string,
days: DayInMonth[],
};
type WeekHead = {
name: string,
narrow: string,
weekend: false
};
type MonthWeeksTable = {
calendar: string,
calendarName: string,
calendarNameAbbr: string,
head: WeekHead[],
weeks: DayInMonth[] | boolean[],
};
declare class AasaamDateTime {
/**
* IANA timezone
*
* @returns {string}
*/
static public getTimeZone(): string
/**
* Create AasaamDateTime
*
* @param {Date|Number} date Standard JavaScript Date object or integer unix time
* @param {('ar'|'az'|'bn'|'de'|'en'|'es'|'fa'|'fr'|'hi'|'id'|'it'|'ja'|'ko'|'ku'|'nl'|'pl'|'ps'|'pt'|'ru'|'sw'|'tr'|'ur'|'zh')} language ISO 639-1 language code
* @param {Language} language ISO 639-1 language code
*/
constructor(date?: Date | number = new Date(), language?: Language = 'fa');
/**
* @param {Language} language ISO 639-1 language code
* @throws {Error}
* @return {AasaamDateTime}
*/
public setLanguage(language: Language): AasaamDateTime
/**
* @param {Date} date Standard JavaScript Date object
* @throws {Error}
* @return {AasaamDateTime}
*/
public setDate(date: Date): AasaamDateTime
/**
* @param {number} unixTime Unix time integer in milliseconds
* @return {AasaamDateTime}
*/
public setUnixTime(unixTime: number): AasaamDateTime
/**
* @return {number}
*/
public getUnixTime(): number
/**
* @returns {Date}
*/
public getDate(): Date
/**
* @param {number} hours Hour number between 0-23
* @return {AasaamDateTime}
*/
public setHours(hours: number): AasaamDateTime
/**
* @param {number} minutes Minute number between 0-59
* @return {AasaamDateTime}
*/
public setMinutes(minutes: number): AasaamDateTime
/**
* @param {number} seconds Second number between 0-59
* @return {AasaamDateTime}
*/
public setSeconds(seconds: number): AasaamDateTime
/**
* @param {number} country ISO 3166-2 country code
* @return {AasaamDateTime}
*/
public changeCountry(country: string): AasaamDateTime
/**
* @return {string}
*/
public getCountry(): string
/**
* @param {Calendar} calendar Calendar type
* @return {MomentGeorgian|MomentHijri|MomentJalaali}
*/
public getMoment(calendar?: Calendar = undefined): MomentGeorgian | MomentHijri | MomentJalaali;
/**
* @param {number} offset Could be negative or positive number
* @param {Calendar} calendar Calendar type
* @return {AasaamDateTime}
*/
public yearOffset(offset: number, calendar?: Calendar = undefined): AasaamDateTime;
/**
* @param {number} offset Could be negative or positive number
* @param {Calendar} calendar Calendar type
* @return {AasaamDateTime}
*/
public monthOffset(offset: number, calendar?: Calendar = undefined): AasaamDateTime;
/**
* @param {number} offset Could be negative or positive number
* @param {Calendar} calendar Calendar type
* @return {AasaamDateTime}
*/
public dayOffset(offset: number, calendar?: Calendar = undefined): AasaamDateTime;
/**
* ISO format object
*
* Return object contains standard ISO 8601 Date
* - `H` _Hour, (0-23), one or two digit_ (**۴**)
* - `HH` _Hour, (00-23), two digit_ (**۰۴**)
* - `m` _Minute, (0-59), one or two digit_ (**۵**)
* - `mm` _Minute, (00-59), two digit_ (**۰۵**)
* - `s` _Second, (0-59), one or two digit_ (**۶**)
* - `ss` _Second, (00-59), two digit_ (**۰۶**)
* - `YYYY` _Year according to ISO 8601, at least four digit_ (**۱۳۸۰**)
* - `YY` _Year according to ISO 8601, at least two digit_ (**۸۰**)
* - `MMMM` _Month, localized, complete_ (**اردیبهشت**)
* - `MM` _Month, two digit_ (**۰۲**)
* - `M` _Month, one or two digit_ (**۲**)
* - `d` _Day of the month, one or two digit_ (**۹**)
* - `dd` _Day of the month, two digit_ (**۰۹**)
* - `E` _Day of the week, localized, number, one char_ (**۱**)
* - `EEEE` _Day of the week, localized, complete_ (**یکشنبه**)
* - `EE` _Day of the week, localized, abbreviated, one char_ (**ی**)
* - `e` _Day of the week, Sunday 0 to Saturday 6_ (**0**)
* - `G` _Epoch, localized, abbreviated_ (**ه.ش.**)
* - `GGGG` _Epoch, localized, complete_ (**هجری شمسی**)
* - `zzzz` _Time zone, NOT localized, complete_ (**Asia/Tehran**)
* - `c` _Calendar type_ (**p**)
*
* @param {Language} language ISO 639-1 language code
* @param {Calendar} calendar Calendar type
* @return {ISOFormatObject}
*/
public isoFormatObject(language?: Language = undefined, calendar?: Calendar = undefined): ISOFormatObject;
/**
* Moment format
*
* @param {string} format Strong contain ISO 8601 formats
* @param {Language} language ISO 639-1 language code
* @return {string}
*/
public momentFormat(format: string, language?: Language = undefined): string;
/**
* Moment parse
*
* @param {string} string String want to parse
* @param {string} format String contain ISO 8601 formats
* @param {Calendar} calendar Calendar type
* @return {AasaamDateTime}
*/
public momentParse(string: string, format: string, calendar?: Calendar = undefined): AasaamDateTime;
/**
* @param {Calendar} calendar Calendar type
* @param {number} offset Offset of before and after
* @return {YearItem[]}
*/
public generateYearList(calendar?: Calendar = undefined, offset?: number = 60): YearItem[]
/**
* @param {Calendar} calendar Calendar type
* @return {MonthItem[]}
*/
public generateMonthList(calendar?: Calendar = undefined): MonthItem[]
/**
* @param {Date} date Standard JavaScript Date object
* @param {Calendar} calendar Calendar type
* @return {SpecialDay}
*/
public getAlternateCalendarData(date: Date, calendar: Calendar): SpecialDay
/**
* @param {Calendar[]} calendarList Calendar type
* @return {MonthWeekDays}
*/
public generateMonthWeekDays(calendarList: Calendar[] = []): MonthWeekDays
/**
* @param {Calendar[]} calendarList Calendar type
* @return {MonthWeeksTable}
*/
public generateMonthWeekTable(calendarList: Calendar[] = []): MonthWeeksTable
}
export const momentG: MomentGeorgian;
export const momentH: MomentHijri;
export const momentJ: MomentJalaali;
export const languages: Language[];
export const preferredCalendars: PreferredCalendars;
export const CALENDAR_TYPE_GREGORIAN: string = 'g';
export const CALENDAR_TYPE_ISLAMIC: string = 'i';
export const CALENDAR_TYPE_PERSIAN: string = 'p';
export const AasaamDateTime: AasaamDateTime;