@react-fabric/date 1.0.0-beta.9 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +2 -9
  2. package/{src/components/Date.module.css → css/_date.css} +5 -5
  3. package/{src/superdate/SuperDate.module.css → css/styles.css} +2 -8
  4. package/dist/cjs/components/DateCell.js +5 -7
  5. package/dist/cjs/components/DateHeader.js +27 -20
  6. package/dist/cjs/components/DatePage.js +10 -12
  7. package/dist/cjs/components/DecadePage.js +3 -3
  8. package/dist/cjs/components/MonthPage.js +3 -3
  9. package/dist/cjs/components/TimeSliders.js +36 -35
  10. package/dist/cjs/components/YearPage.js +3 -3
  11. package/dist/cjs/display/DateDisplay.js +25 -8
  12. package/dist/cjs/display/DateDuration.js +155 -0
  13. package/dist/cjs/hijri/DateConverter.js +154 -0
  14. package/dist/cjs/hijri/FormatDate.js +116 -0
  15. package/dist/cjs/hijri/HijriDate.js +531 -0
  16. package/dist/cjs/hijri/StringDateParser.js +74 -0
  17. package/dist/cjs/hijri/index.js +15 -1025
  18. package/dist/cjs/hijri/initializer.js +113 -0
  19. package/dist/cjs/hijri/locales.js +19 -0
  20. package/dist/cjs/hijri/safe.js +17 -0
  21. package/dist/cjs/i18n/ar/date.json.js +213 -0
  22. package/dist/cjs/i18n/en/date.json.js +83 -0
  23. package/dist/cjs/i18n/index.js +4 -10
  24. package/dist/cjs/index.js +41 -2
  25. package/dist/cjs/panels/BasePanel.js +6 -5
  26. package/dist/cjs/panels/DatePanel.js +45 -21
  27. package/dist/cjs/{superdate → panels}/EventPanel.js +28 -12
  28. package/dist/cjs/panels/RangePanel.js +49 -19
  29. package/dist/cjs/utils/dateUtil.js +3 -5
  30. package/dist/esm/components/DateCell.js +6 -8
  31. package/dist/esm/components/DateHeader.js +28 -21
  32. package/dist/esm/components/DatePage.js +11 -13
  33. package/dist/esm/components/DecadePage.js +3 -3
  34. package/dist/esm/components/MonthPage.js +3 -3
  35. package/dist/esm/components/TimeSliders.js +38 -37
  36. package/dist/esm/components/YearPage.js +3 -3
  37. package/dist/esm/display/DateDisplay.js +26 -9
  38. package/dist/esm/display/DateDuration.js +155 -0
  39. package/dist/esm/hijri/DateConverter.js +152 -0
  40. package/dist/esm/hijri/FormatDate.js +113 -0
  41. package/dist/esm/hijri/HijriDate.js +528 -0
  42. package/dist/esm/hijri/StringDateParser.js +74 -0
  43. package/dist/esm/hijri/index.js +15 -1025
  44. package/dist/esm/hijri/initializer.js +113 -0
  45. package/dist/esm/hijri/locales.js +18 -0
  46. package/dist/esm/hijri/safe.js +14 -0
  47. package/dist/esm/i18n/ar/date.json.js +209 -0
  48. package/dist/esm/i18n/en/date.json.js +79 -0
  49. package/dist/esm/i18n/index.js +2 -8
  50. package/dist/esm/index.js +36 -1
  51. package/dist/esm/panels/BasePanel.js +6 -5
  52. package/dist/esm/panels/DatePanel.js +48 -24
  53. package/dist/esm/{superdate → panels}/EventPanel.js +29 -13
  54. package/dist/esm/panels/RangePanel.js +52 -22
  55. package/dist/esm/utils/dateUtil.js +4 -6
  56. package/dist/types/components/DateCell.d.ts +1 -1
  57. package/dist/types/components/DateHeader.d.ts +1 -1
  58. package/dist/types/components/DatePage.d.ts +1 -1
  59. package/dist/types/components/DecadePage.d.ts +1 -1
  60. package/dist/types/components/MonthPage.d.ts +1 -1
  61. package/dist/types/components/TimeSliders.d.ts +1 -1
  62. package/dist/types/components/YearPage.d.ts +1 -1
  63. package/dist/types/display/DateDisplay.d.ts +17 -4
  64. package/dist/types/display/DateDuration.d.ts +25 -0
  65. package/dist/types/hijri/DateConverter.d.ts +13 -0
  66. package/dist/types/hijri/FormatDate.d.ts +19 -0
  67. package/dist/types/hijri/HijriDate.d.ts +214 -0
  68. package/dist/types/hijri/StringDateParser.d.ts +11 -0
  69. package/dist/types/hijri/index.d.ts +2 -2
  70. package/dist/types/hijri/initializer.d.ts +129 -0
  71. package/dist/types/hijri/locales.d.ts +19 -0
  72. package/dist/types/hijri/safe.d.ts +3 -0
  73. package/dist/types/index.d.ts +32 -1
  74. package/dist/types/panels/BasePanel.d.ts +1 -1
  75. package/dist/types/panels/DatePanel.d.ts +22 -1
  76. package/dist/types/panels/EventPanel.d.ts +17 -0
  77. package/dist/types/panels/RangePanel.d.ts +19 -1
  78. package/dist/types/types/index.d.ts +8 -40
  79. package/package.json +14 -21
  80. package/src/components/DateCell.tsx +20 -75
  81. package/src/components/DateHeader.tsx +27 -78
  82. package/src/components/DatePage.tsx +11 -36
  83. package/src/components/DecadePage.tsx +2 -2
  84. package/src/components/MonthPage.tsx +2 -2
  85. package/src/components/TimeSliders.tsx +20 -60
  86. package/src/components/YearPage.tsx +2 -2
  87. package/src/display/DateDisplay.tsx +26 -38
  88. package/src/display/DateDuration.tsx +170 -0
  89. package/src/hijri/DateConverter.js +175 -0
  90. package/src/hijri/FormatDate.js +134 -0
  91. package/src/hijri/HijriDate.js +477 -0
  92. package/src/hijri/StringDateParser.js +68 -0
  93. package/src/hijri/index.js +16 -1535
  94. package/src/hijri/initializer.js +96 -0
  95. package/src/hijri/locales.js +109 -0
  96. package/src/hijri/safe.js +16 -0
  97. package/src/i18n/ar/date.json +203 -0
  98. package/src/i18n/en/date.json +73 -0
  99. package/src/i18n/index.ts +2 -5
  100. package/src/index.ts +29 -18
  101. package/src/panels/BasePanel.tsx +7 -10
  102. package/src/panels/DatePanel.tsx +41 -33
  103. package/src/{superdate → panels}/EventPanel.tsx +52 -53
  104. package/src/panels/RangePanel.tsx +54 -60
  105. package/src/types/index.ts +8 -43
  106. package/src/utils/dateUtil.ts +26 -82
  107. package/dist/cjs/components/Date.module.css +0 -1
  108. package/dist/cjs/i18n/ar.json.js +0 -25
  109. package/dist/cjs/i18n/en.json.js +0 -21
  110. package/dist/cjs/i18n/superdate/ar.json.js +0 -86
  111. package/dist/cjs/i18n/superdate/en.json.js +0 -93
  112. package/dist/cjs/superdate/QuickSelect.js +0 -134
  113. package/dist/cjs/superdate/RelativeInput.js +0 -79
  114. package/dist/cjs/superdate/RelativePanel.js +0 -91
  115. package/dist/cjs/superdate/SuperDate.module.css +0 -1
  116. package/dist/cjs/superdate/Superdate.js +0 -177
  117. package/dist/esm/components/Date.module.css +0 -1
  118. package/dist/esm/i18n/ar.json.js +0 -21
  119. package/dist/esm/i18n/en.json.js +0 -18
  120. package/dist/esm/i18n/superdate/ar.json.js +0 -79
  121. package/dist/esm/i18n/superdate/en.json.js +0 -85
  122. package/dist/esm/superdate/QuickSelect.js +0 -134
  123. package/dist/esm/superdate/RelativeInput.js +0 -79
  124. package/dist/esm/superdate/RelativePanel.js +0 -91
  125. package/dist/esm/superdate/SuperDate.module.css +0 -1
  126. package/dist/esm/superdate/Superdate.js +0 -176
  127. package/dist/types/superdate/EventPanel.d.ts +0 -4
  128. package/dist/types/superdate/QuickSelect.d.ts +0 -1
  129. package/dist/types/superdate/RelativeInput.d.ts +0 -1
  130. package/dist/types/superdate/RelativePanel.d.ts +0 -1
  131. package/dist/types/superdate/Superdate.d.ts +0 -17
  132. package/src/i18n/ar.json +0 -14
  133. package/src/i18n/en.json +0 -13
  134. package/src/i18n/superdate/ar.json +0 -70
  135. package/src/i18n/superdate/en.json +0 -75
  136. package/src/superdate/QuickSelect.tsx +0 -121
  137. package/src/superdate/RelativeInput.tsx +0 -64
  138. package/src/superdate/RelativePanel.tsx +0 -103
  139. package/src/superdate/Superdate.tsx +0 -198
@@ -1,1540 +1,21 @@
1
- // @github : https://github.com/abdennour/hijri-date
1
+ import HijriDate, {
2
+ toHijri
3
+ } from './safe';
2
4
 
3
- /* eslint-disable */
4
-
5
- (function e(t, n, r) {
6
- function s(o, u) {
7
- if (!n[o]) {
8
- if (!t[o]) {
9
- const a = typeof require === "function" && require;
10
- if (!u && a) return a(o, !0);
11
- if (i) return i(o, !0);
12
- const f = new Error("Cannot find module '" + o + "'");
13
- throw ((f.code = "MODULE_NOT_FOUND"), f);
14
- }
15
- const l = (n[o] = { exports: {} });
16
- t[o][0].call(
17
- l.exports,
18
- function (e) {
19
- const n = t[o][1][e];
20
- return s(n || e);
21
- },
22
- l,
23
- l.exports,
24
- e,
25
- t,
26
- n,
27
- r,
28
- );
29
- }
30
- return n[o].exports;
5
+ const globalScope = (() => {
6
+ if (typeof window === 'object') {
7
+ return window;
31
8
  }
32
- var i = typeof require === "function" && require;
33
- for (let o = 0; o < r.length; o++) s(r[o]);
34
- return s;
35
- })(
36
- {
37
- 1: [
38
- function (require, module, exports) {
39
- module.exports = require("./lib/index.js");
40
- },
41
- { "./lib/index.js": 6 },
42
- ],
43
- 2: [
44
- function (require, module, exports) {
45
- "use strict";
46
-
47
- Object.defineProperty(exports, "__esModule", {
48
- value: true,
49
- });
50
- exports.weekDay = weekDay;
51
- function intPart(floatNum) {
52
- if (floatNum < -0.0000001) {
53
- return Math.ceil(floatNum - 0.0000001);
54
- }
55
- return Math.floor(floatNum + 0.0000001);
56
- }
57
- const delta = 1;
58
-
59
- function GregToIsl(arg) {
60
- let d = parseInt(arg.CDay.value);
61
- let m = parseInt(arg.CMonth.value);
62
- let y = parseInt(arg.CYear.value);
63
- let jd = void 0;
64
- let l = void 0;
65
- let jd1 = void 0;
66
- let n = void 0;
67
- let j = void 0;
68
- const delta = 1;
69
- if (
70
- y > 1582 ||
71
- (y == 1582 && m > 10) ||
72
- (y == 1582 && m == 10 && d > 14)
73
- ) {
74
- jd =
75
- intPart((1461 * (y + 4800 + intPart((m - 14) / 12))) / 4) +
76
- intPart((367 * (m - 2 - 12 * intPart((m - 14) / 12))) / 12) -
77
- intPart(
78
- (3 * intPart((y + 4900 + intPart((m - 14) / 12)) / 100)) / 4,
79
- ) +
80
- d -
81
- 32075 +
82
- delta;
83
- } else {
84
- jd =
85
- 367 * y -
86
- intPart((7 * (y + 5001 + intPart((m - 9) / 7))) / 4) +
87
- intPart((275 * m) / 9) +
88
- d +
89
- 1729777 +
90
- delta;
91
- }
92
-
93
- jd1 = jd - delta;
94
- l = jd - 1948440 + 10632;
95
- n = intPart((l - 1) / 10631);
96
- l = l - 10631 * n + 354;
97
- j =
98
- intPart((10985 - l) / 5316) * intPart((50 * l) / 17719) +
99
- intPart(l / 5670) * intPart((43 * l) / 15238);
100
- l =
101
- l -
102
- intPart((30 - j) / 15) * intPart((17719 * j) / 50) -
103
- intPart(j / 16) * intPart((15238 * j) / 43) +
104
- 29;
105
- m = intPart((24 * l) / 709);
106
- d = l - intPart((709 * m) / 24);
107
- y = 30 * n + j - 30;
108
-
109
- return {
110
- d,
111
- m,
112
- y,
113
- dateOfWeek: jd1 % 7,
114
- dayName: weekDay(jd1 % 7),
115
- };
116
- }
117
-
118
- function IslToGreg(arg) {
119
- let d = parseInt(arg.HDay.value);
120
- let m = parseInt(arg.HMonth.value);
121
- let y = parseInt(arg.HYear.value);
122
-
123
- const jd =
124
- intPart((11 * y + 3) / 30) +
125
- 354 * y +
126
- 30 * m -
127
- intPart((m - 1) / 2) +
128
- d +
129
- 1948440 -
130
- 385 -
131
- delta;
132
-
133
- let l = void 0;
134
- let n = void 0;
135
- let i = void 0;
136
- let j = void 0;
137
- let k = void 0;
138
-
139
- if (jd > 2299160) {
140
- l = jd + 68569;
141
- n = intPart((4 * l) / 146097);
142
- l = l - intPart((146097 * n + 3) / 4);
143
- i = intPart((4000 * (l + 1)) / 1461001);
144
- l = l - intPart((1461 * i) / 4) + 31;
145
- j = intPart((80 * l) / 2447);
146
- d = l - intPart((2447 * j) / 80);
147
- l = intPart(j / 11);
148
- m = j + 2 - 12 * l;
149
- y = 100 * (n - 49) + i + l;
150
- } else {
151
- j = jd + 1402;
152
- k = intPart((j - 1) / 1461);
153
- l = j - 1461 * k;
154
- n = intPart((l - 1) / 365) - intPart(l / 1461);
155
- i = l - 365 * n + 30;
156
- j = intPart((80 * i) / 2447);
157
- d = i - intPart((2447 * j) / 80);
158
- i = intPart(j / 11);
159
- m = j + 2 - 12 * i;
160
- y = 4 * k + n + i - 4716;
161
- }
162
-
163
- return {
164
- d,
165
- m,
166
- y,
167
- dateOfWeek: jd % 7,
168
- dayName: weekDay(jd % 7),
169
- };
170
- }
171
-
172
- function weekDay(wdn) {
173
- if (wdn == 0) {
174
- return "Mon";
175
- }
176
- if (wdn == 1) {
177
- return "Tue";
178
- }
179
- if (wdn == 2) {
180
- return "Wed";
181
- }
182
- if (wdn == 3) {
183
- return "Thu";
184
- }
185
- if (wdn == 4) {
186
- return "Fri";
187
- }
188
- if (wdn == 5) {
189
- return "Sat";
190
- }
191
- if (wdn == 6) {
192
- return "Sun";
193
- }
194
- return "";
195
- }
196
-
197
- function GregToHijri(gregDate) {
198
- const hijriDate = GregToIsl({
199
- CDay: {
200
- value: gregDate.getDate(),
201
- },
202
- CYear: {
203
- value: gregDate.getFullYear(),
204
- },
205
- CMonth: {
206
- value: gregDate.getMonth() + 1,
207
- },
208
- });
209
-
210
- return {
211
- year: hijriDate.y,
212
- month: hijriDate.m,
213
- date: hijriDate.d,
214
- hours: gregDate.getHours(),
215
- minutes: gregDate.getMinutes(),
216
- seconds: gregDate.getSeconds(),
217
- milliseconds: gregDate.getMilliseconds(),
218
- day: hijriDate.dateOfWeek,
219
- dayName: hijriDate.dayName,
220
- };
221
- }
222
-
223
- function HijriToGreg(hijriDate) {
224
- const gregDate = IslToGreg({
225
- HDay: {
226
- value: hijriDate._date || hijriDate.date,
227
- },
228
- HYear: {
229
- value: hijriDate._year || hijriDate.year,
230
- },
231
- HMonth: {
232
- value: hijriDate._month || hijriDate.month,
233
- },
234
- });
235
-
236
- return new Date(
237
- gregDate.y,
238
- gregDate.m - 1,
239
- gregDate.d,
240
- hijriDate.getHours(),
241
- hijriDate.getMinutes(),
242
- hijriDate.getSeconds(),
243
- hijriDate.getMilliseconds(),
244
- );
245
- }
246
-
247
- exports.GregToHijri = GregToHijri;
248
- exports.HijriToGreg = HijriToGreg;
249
- },
250
- {},
251
- ],
252
- 3: [
253
- function (require, module, exports) {
254
- "use strict";
255
-
256
- Object.defineProperty(exports, "__esModule", {
257
- value: true,
258
- });
259
- const dateFormat = (function () {
260
- const token =
261
- /P{1,4}|p{1,4}|d{1,2}|e{3,6}|M{1,4}|yy(?:yy)?|([Hhms])\1?|[a]{1,4}|[LloSZ]|('at')|"[^"]*"|'[^']*'/g;
262
- const timezone =
263
- /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
264
- const timezoneClip = /[^-+\dA-Z]/g;
265
- const pad = function pad(val, len) {
266
- val = String(val);
267
- len = len || 2;
268
- while (val.length < len) {
269
- val = "0" + val;
270
- }
271
- return val;
272
- };
273
-
274
- return function (date, mask) {
275
- const options =
276
- arguments.length > 2 && arguments[2] !== undefined
277
- ? arguments[2]
278
- : {
279
- utc: false,
280
- };
281
-
282
- const _require$default = require("./HijriDate").default;
283
- const locales = _require$default.locales;
284
- const defaultLocale = _require$default.defaultLocale;
285
-
286
- options.locale = options.locale === "ar" ? "ar" : "en";
287
- if (!locales[options.locale]) {
288
- throw new Error(
289
- "Locale " +
290
- options.locale +
291
- ' is not supported yet .\n Please, try to extend "HijriDate.locales" :\n i.e: HijriDate.locales.' +
292
- options.locale +
293
- " = {dayNames:[..14 items..], monthNames:[..24 items..]}\n ",
294
- );
295
- return;
296
- }
297
-
298
- if (
299
- arguments.length == 1 &&
300
- Object.prototype.toString.call(date) == "[object String]" &&
301
- !/\d/.test(date)
302
- ) {
303
- mask = date;
304
- date = undefined;
305
- }
306
-
307
- mask = String(masks[mask] || mask || masks.default);
308
-
309
- if (mask.slice(0, 4) == "UTC:") {
310
- mask = mask.slice(4);
311
- options.utc = true;
312
- }
313
-
314
- const _ = options.utc ? "getUTC" : "get";
315
- const d = date[_ + "Date"]();
316
- const D = date[_ + "Day"]();
317
- const M = date[_ + "Month"]();
318
- const mIndex = date[_ + "MonthIndex"]();
319
- const y = date[_ + "FullYear"]();
320
- const H = date[_ + "Hours"]();
321
- const m = date[_ + "Minutes"]();
322
- const s = date[_ + "Seconds"]();
323
- const L = date[_ + "Milliseconds"]();
324
- const o = options.utc ? 0 : date.getTimezoneOffset();
325
- const flags = {
326
- d,
327
- dd: pad(d),
328
- ee: locales[options.locale].dayNames[D],
329
- eee: locales[options.locale].dayNames[D + 7],
330
- eeee: locales[options.locale].dayNames[D + 14],
331
- eeeeee: locales[options.locale].dayNames[D],
332
- M,
333
- MM: pad(M),
334
- MMM: locales[options.locale].monthNames[mIndex],
335
- MMMM: locales[options.locale].monthNames[mIndex + 12],
336
- yy: String(y).slice(2),
337
- yyyy: y,
338
- h: H % 12 || 12,
339
- hh: pad(H % 12 || 12),
340
- H,
341
- HH: pad(H),
342
- m,
343
- mm: pad(m),
344
- s,
345
- ss: pad(s),
346
- l: pad(L, 3),
347
- L: pad(L > 99 ? Math.round(L / 10) : L),
348
- a:
349
- H < 12
350
- ? locales[options.locale].am
351
- : locales[options.locale].pm,
352
- aa:
353
- H < 12
354
- ? locales[options.locale].am
355
- : locales[options.locale].pm,
356
- aaa:
357
- H < 12
358
- ? locales[options.locale].am
359
- : locales[options.locale].pm,
360
- aaaa:
361
- H < 12
362
- ? locales[options.locale].am
363
- : locales[options.locale].pm,
364
- aaaaa:
365
- H < 12
366
- ? locales[options.locale].am
367
- : locales[options.locale].pm,
368
- "'at'": locales[options.locale].separator,
369
- o:
370
- (o > 0 ? "-" : "+") +
371
- pad(Math.floor(Math.abs(o) / 60) * 100 + (Math.abs(o) % 60), 4),
372
- S: ["th", "st", "nd", "rd"][
373
- d % 10 > 3 ? 0 : (((d % 100) - (d % 10) != 10) * d) % 10
374
- ],
375
- };
376
-
377
- return mask.replace(token, function ($0) {
378
- if ($0 === "P") return `${flags.d}/${flags.M}/${flags.yyyy} `;
379
- if ($0.startsWith("PP"))
380
- return `${flags.MMM} ${flags.dd}, ${flags.yyyy} `;
381
- if ($0 === "p") return `${flags.h}:${flags.m} ${flags.a}`;
382
- if ($0.startsWith("pp"))
383
- return `${flags.hh}:${flags.mm}:${flags.ss} ${flags.a}`;
384
- return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
385
- });
386
- };
387
- })();
388
-
389
- var masks = (exports.masks = {
390
- default: "ddd MMM dd yyyy HH:mm:ss",
391
- shortDate: "M/d/yy",
392
- mediumDate: "MMM d, yyyy",
393
- longDate: "MMMm d, yyyy",
394
- fullDate: "dddd, MMMM d, yyyy",
395
- shortTime: "h:mm TT",
396
- mediumTime: "h:mm:ss TT",
397
- longTime: "h:mm:ss TT Z",
398
- isoDate: "yyyy-MM-dd",
399
- isoTime: "HH:mm:ss",
400
- isoDateTime: "yyyy-MM-dd'T'HH:mm:ss",
401
- isoUtcDateTime: "UTC:yyyy-MM-dd'T'HH:mm:ss'Z'",
402
- });
403
-
404
- exports.default = dateFormat;
405
- },
406
- { "./HijriDate": 4 },
407
- ],
408
- 4: [
409
- function (require, module, exports) {
410
- "use strict";
411
-
412
- Object.defineProperty(exports, "__esModule", {
413
- value: true,
414
- });
415
- exports.dateProps = undefined;
416
-
417
- const _typeof =
418
- typeof Symbol === "function" && typeof Symbol.iterator === "symbol"
419
- ? function (obj) {
420
- return typeof obj;
421
- }
422
- : function (obj) {
423
- return obj &&
424
- typeof Symbol === "function" &&
425
- obj.constructor === Symbol &&
426
- obj !== Symbol.prototype
427
- ? "symbol"
428
- : typeof obj;
429
- };
430
-
431
- const _createClass = (function () {
432
- function defineProperties(target, props) {
433
- for (let i = 0; i < props.length; i++) {
434
- const descriptor = props[i];
435
- descriptor.enumerable = descriptor.enumerable || false;
436
- descriptor.configurable = true;
437
- if ("value" in descriptor) descriptor.writable = true;
438
- Object.defineProperty(target, descriptor.key, descriptor);
439
- }
440
- }
441
- return function (Constructor, protoProps, staticProps) {
442
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
443
- if (staticProps) defineProperties(Constructor, staticProps);
444
- return Constructor;
445
- };
446
- })();
447
-
448
- const _DateConverter = require("./DateConverter");
449
-
450
- const _initializer = require("./initializer");
451
-
452
- const _initializer2 = _interopRequireDefault(_initializer);
453
-
454
- const _FormatDate = require("./FormatDate");
455
-
456
- const _FormatDate2 = _interopRequireDefault(_FormatDate);
457
-
458
- const _locales = require("./locales");
459
-
460
- function _interopRequireDefault(obj) {
461
- return obj && obj.__esModule ? obj : { default: obj };
462
- }
463
-
464
- function _classCallCheck(instance, Constructor) {
465
- if (!(instance instanceof Constructor)) {
466
- throw new TypeError("Cannot call a class as a function");
467
- }
468
- }
469
-
470
- const HijriDate = (function () {
471
- function HijriDate() {
472
- _classCallCheck(this, HijriDate);
473
-
474
- return this.init.apply(this, arguments);
475
- }
476
-
477
- _createClass(
478
- HijriDate,
479
- [
480
- {
481
- key: "init",
482
- value: function init() {
483
- const _this = this;
484
-
485
- let props = {};
486
- if (!arguments.length) {
487
- props = _initializer2.default.initDefault();
488
- } else {
489
- try {
490
- const methodNameSuffix = Array.from(arguments)
491
- .map(function (arg) {
492
- return typeof arg === "undefined"
493
- ? "undefined"
494
- : _typeof(arg);
495
- })
496
- .join("_");
497
- props = _initializer2.default[
498
- "init_" + methodNameSuffix
499
- ].apply(_initializer2.default, arguments);
500
- } catch (e) {
501
- throw new TypeError(
502
- hijriTypeErrorMessage + "\n--- Details:\n" + e,
503
- );
504
- }
505
- }
506
-
507
- Object.keys(props).forEach(function (prop) {
508
- _this["_" + prop] = props[prop];
509
- });
510
- this.__proxy__ = (0, _DateConverter.HijriToGreg)(this);
511
- this.initDayOfWeek();
512
- return this;
513
- },
514
- },
515
- {
516
- key: "initDayOfWeek",
517
- value: function initDayOfWeek() {
518
- if (!this.__proxy__) return;
519
- this._day = this._day || this.__proxy__.getDay();
520
- this._dayName =
521
- this._dayName || (0, _DateConverter.weekDay)(this._day);
522
- },
523
- },
524
- {
525
- key: "getFullYear",
526
- value: function getFullYear() {
527
- return this.year;
528
- },
529
- },
530
- {
531
- key: "getMonthIndex",
532
- value: function getMonthIndex() {
533
- return this.month - 1;
534
- },
535
- },
536
- {
537
- key: "getMonth",
538
- value: function getMonth() {
539
- return this.month;
540
- },
541
- },
542
- {
543
- key: "getDate",
544
- value: function getDate() {
545
- return this.date;
546
- },
547
- },
548
- {
549
- key: "getDay",
550
- value: function getDay() {
551
- return this.day;
552
- },
553
- },
554
- {
555
- key: "getHours",
556
- value: function getHours() {
557
- return this.hours;
558
- },
559
- },
560
- {
561
- key: "getMinutes",
562
- value: function getMinutes() {
563
- return this.minutes;
564
- },
565
- },
566
- {
567
- key: "getSeconds",
568
- value: function getSeconds() {
569
- return this.seconds;
570
- },
571
- },
572
- {
573
- key: "getMilliseconds",
574
- value: function getMilliseconds() {
575
- return this.milliseconds;
576
- },
577
- },
578
- {
579
- key: "getTime",
580
- value: function getTime() {
581
- return this.time;
582
- },
583
- },
584
- {
585
- key: "getTimezoneOffset",
586
- value: function getTimezoneOffset() {
587
- return this.timezoneOffset;
588
- },
589
- },
590
- {
591
- key: "addDay",
592
- value: function addDay() {
593
- return this.addHours(24);
594
- },
595
- },
596
- {
597
- key: "addDays",
598
- value: function addDays(days) {
599
- const _this2 = this;
600
-
601
- if (typeof days === "number")
602
- Array.from(
603
- {
604
- length: days,
605
- },
606
- function (v, k) {
607
- return k + 1;
608
- },
609
- ).forEach(function (i) {
610
- return _this2.addDay();
611
- });
612
- return this;
613
- },
614
- },
615
- {
616
- key: "addHours",
617
- value: function addHours(n) {
618
- return this.addMinutes(n * 60);
619
- },
620
- },
621
- {
622
- key: "addMinutes",
623
- value: function addMinutes(n) {
624
- return this.addSeconds(n * 60);
625
- },
626
- },
627
- {
628
- key: "addSeconds",
629
- value: function addSeconds(n) {
630
- return this.addMilliseconds(1000 * n);
631
- },
632
- },
633
- {
634
- key: "addMilliseconds",
635
- value: function addMilliseconds(n) {
636
- this.time += n;
637
- return this;
638
- },
639
- },
640
- {
641
- key: "subtractDays",
642
- value: function subtractDays(days) {
643
- const _this3 = this;
644
-
645
- Array.from(
646
- {
647
- length: Math.abs(days),
648
- },
649
- function (v, k) {
650
- return k + 1;
651
- },
652
- ).forEach(function (i) {
653
- return _this3.subtractDay();
654
- });
655
- return this;
656
- },
657
- },
658
- {
659
- key: "subtractDay",
660
- value: function subtractDay() {
661
- return this.subtractHours(24);
662
- },
663
- },
664
- {
665
- key: "subtractHours",
666
- value: function subtractHours(n) {
667
- return this.subtractMinutes(n * 60);
668
- },
669
- },
670
- {
671
- key: "subtractMinutes",
672
- value: function subtractMinutes(n) {
673
- return this.subtractSeconds(n * 60);
674
- },
675
- },
676
- {
677
- key: "subtractSeconds",
678
- value: function subtractSeconds(n) {
679
- return this.subtractMilliseconds(1000 * n);
680
- },
681
- },
682
- {
683
- key: "subtractMilliseconds",
684
- value: function subtractMilliseconds(n) {
685
- return this.addMilliseconds(-n);
686
- },
687
- },
688
- {
689
- key: "updateProxy",
690
- value: function updateProxy() {
691
- this.__proxy__ = (0, _DateConverter.HijriToGreg)(this);
692
- return this;
693
- },
694
- },
695
- {
696
- key: "toGregorian",
697
- value: function toGregorian() {
698
- return this.__proxy__;
699
- },
700
- },
701
- {
702
- key: "format",
703
- value: function format(mask, options) {
704
- return _FormatDate2.default.apply(
705
- undefined,
706
- [this].concat(Array.prototype.slice.call(arguments)),
707
- );
708
- },
709
- },
710
- {
711
- key: "ignoreTime",
712
- value: function ignoreTime() {
713
- this.hours = 0;
714
- this.minutes = 0;
715
- this.seconds = 0;
716
- this.milliseconds = 0;
717
- this.updateProxy();
718
- return this;
719
- },
720
- },
721
- {
722
- key: "clone",
723
- value: function clone() {
724
- return new HijriDate(this.time);
725
- },
726
- },
727
- {
728
- key: "is",
729
- value: function is() {
730
- const _arguments = arguments;
731
- const _this4 = this;
732
-
733
- if (!arguments.length)
734
- throw new Error(
735
- "function cannot be called without arguments",
736
- );
737
- if (
738
- arguments.length === 1 &&
739
- _typeof(arguments[0]) === "object" &&
740
- Object.keys(arguments[0]).length
741
- )
742
- return Object.keys(arguments[0]).every(function (prop) {
743
- return (
744
- parseInt(_arguments[0][prop]) === parseInt(_this4[prop])
745
- );
746
- });
747
- return Array.from(arguments).every(function (arg, i) {
748
- return arg === _this4[dateProps[i]];
749
- });
750
- },
751
- },
752
- {
753
- key: "isToday",
754
- value: function isToday() {
755
- return (
756
- HijriDate.today().time == this.clone().ignoreTime().time
757
- );
758
- },
759
- },
760
- {
761
- key: "isYesterday",
762
- value: function isYesterday() {
763
- return (
764
- HijriDate.yesterday().time == this.clone().ignoreTime().time
765
- );
766
- },
767
- },
768
- {
769
- key: "isTomorrow",
770
- value: function isTomorrow() {
771
- return (
772
- HijriDate.tomorrow().time == this.clone().ignoreTime().time
773
- );
774
- },
775
- },
776
- {
777
- key: "valueOf",
778
- value: function valueOf() {
779
- return this.getTime();
780
- },
781
- },
782
- {
783
- key: "toString",
784
- value: function toString() {
785
- return this.format("default");
786
- },
787
- },
788
- {
789
- key: "year",
790
- get: function get() {
791
- return this._year;
792
- },
793
- set: function set(newYear) {
794
- this._year = newYear;
795
- this.updateProxy();
796
- },
797
- },
798
- {
799
- key: "month",
800
- get: function get() {
801
- return this._month;
802
- },
803
- set: function set(newMonth) {
804
- this._month = newMonth;
805
- this.updateProxy();
806
- },
807
- },
808
- {
809
- key: "date",
810
- get: function get() {
811
- return this._date;
812
- },
813
- set: function set(newDate) {
814
- this._date = newDate;
815
- this.updateProxy();
816
- },
817
- },
818
- {
819
- key: "time",
820
- get: function get() {
821
- return this.__proxy__.getTime();
822
- },
823
- set: function set(newTime) {
824
- const _this5 = this;
825
-
826
- const props = _initializer2.default.init_number(newTime);
827
- Object.keys(props).forEach(function (prop) {
828
- _this5["_" + prop] = props[prop];
829
- });
830
- this.__proxy__ = new Date(newTime);
831
- },
832
- },
833
- {
834
- key: "hours",
835
- get: function get() {
836
- return this._hours || 0;
837
- },
838
- set: function set(hours) {
839
- this._hours = hours;
840
- this.updateProxy();
841
- },
842
- },
843
- {
844
- key: "minutes",
845
- get: function get() {
846
- return this._minutes || 0;
847
- },
848
- set: function set(minutes) {
849
- this._minutes = minutes;
850
- this.updateProxy();
851
- },
852
- },
853
- {
854
- key: "seconds",
855
- get: function get() {
856
- return this._seconds || 0;
857
- },
858
- set: function set(seconds) {
859
- this._seconds = seconds;
860
- this.updateProxy();
861
- },
862
- },
863
- {
864
- key: "milliseconds",
865
- get: function get() {
866
- return this._milliseconds || 0;
867
- },
868
- set: function set(milliseconds) {
869
- this._milliseconds = milliseconds;
870
- this.updateProxy();
871
- },
872
- },
873
- {
874
- key: "timezoneOffset",
875
- get: function get() {
876
- return this.__proxy__.getTimezoneOffset();
877
- },
878
- },
879
- {
880
- key: "day",
881
- get: function get() {
882
- return this._day;
883
- },
884
- },
885
- {
886
- key: "dayName",
887
- get: function get() {
888
- return this._dayName;
889
- },
890
- },
891
- ],
892
- [
893
- {
894
- key: "now",
895
- value: function now() {
896
- return Date.now();
897
- },
898
- },
899
- {
900
- key: "today",
901
- value: function today() {
902
- return new HijriDate().ignoreTime();
903
- },
904
- },
905
- {
906
- key: "yesterday",
907
- value: function yesterday() {
908
- return this.today().subtractDay();
909
- },
910
- },
911
- {
912
- key: "tomorrow",
913
- value: function tomorrow() {
914
- return this.today().addDay();
915
- },
916
- },
917
- ],
918
- );
919
-
920
- return HijriDate;
921
- })();
922
-
923
- HijriDate.locales = {
924
- ar: _locales.ar,
925
- en: _locales.en,
926
- };
927
- HijriDate.defaultLocale = "ar";
928
-
929
- var hijriTypeErrorMessage =
930
- "\n Wrong call of constructor !\n Please, try to use of the following constructors:\n \u21E2 new HijriDate() ; //current date\n or\n \u21E2 new HijriDate(year, month, day [, hour][, minutes][, seconds][, milliseconds]);\n .i.e: new HijriDate(1438, 12, 23)\n or\n \u21E2 new HijriDate(date[, format])\n .i.e: new HijriDate('1438-12-23', 'yyyy-mm-dd')\n ";
931
-
932
- var dateProps = (exports.dateProps = [
933
- "year",
934
- "month",
935
- "date",
936
- "hours",
937
- "minutes",
938
- "seconds",
939
- "milliseconds",
940
- ]);
941
- exports.default = HijriDate;
942
- },
943
- {
944
- "./DateConverter": 2,
945
- "./FormatDate": 3,
946
- "./initializer": 7,
947
- "./locales": 8,
948
- },
949
- ],
950
- 5: [
951
- function (require, module, exports) {
952
- "use strict";
953
-
954
- Object.defineProperty(exports, "__esModule", {
955
- value: true,
956
- });
957
-
958
- const _createClass = (function () {
959
- function defineProperties(target, props) {
960
- for (let i = 0; i < props.length; i++) {
961
- const descriptor = props[i];
962
- descriptor.enumerable = descriptor.enumerable || false;
963
- descriptor.configurable = true;
964
- if ("value" in descriptor) descriptor.writable = true;
965
- Object.defineProperty(target, descriptor.key, descriptor);
966
- }
967
- }
968
- return function (Constructor, protoProps, staticProps) {
969
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
970
- if (staticProps) defineProperties(Constructor, staticProps);
971
- return Constructor;
972
- };
973
- })();
974
-
975
- function _classCallCheck(instance, Constructor) {
976
- if (!(instance instanceof Constructor)) {
977
- throw new TypeError("Cannot call a class as a function");
978
- }
979
- }
980
-
981
- const StringDateParser = (function () {
982
- function StringDateParser() {
983
- _classCallCheck(this, StringDateParser);
984
- }
985
-
986
- _createClass(StringDateParser, null, [
987
- {
988
- key: "extract",
989
- value: function extract(string, format, formatChunk) {
990
- const ignoreCase =
991
- arguments.length > 3 && arguments[3] !== undefined
992
- ? arguments[3]
993
- : true;
994
-
995
- const targetFormat = ignoreCase ? format.toLowerCase() : format;
996
- if (targetFormat.includes(formatChunk)) {
997
- return parseInt(
998
- string.substr(
999
- targetFormat.indexOf(formatChunk),
1000
- formatChunk.length,
1001
- ),
1002
- );
1003
- }
1004
- },
1005
- },
1006
- {
1007
- key: "extractYear",
1008
- value: function extractYear(dateString, format) {
1009
- let year = this.extract.apply(
1010
- this,
1011
- Array.prototype.slice.call(arguments).concat(["yyyy"]),
1012
- );
1013
- if (!year) {
1014
- year = this.extract.apply(
1015
- this,
1016
- Array.prototype.slice.call(arguments).concat(["yy"]),
1017
- );
1018
- if (year) year = Number("14" + year);
1019
- }
1020
- return year;
1021
- },
1022
- },
1023
- {
1024
- key: "extractMonth",
1025
- value: function extractMonth(dateString, format) {
1026
- const month = this.extract.apply(
1027
- this,
1028
- Array.prototype.slice.call(arguments).concat(["mm", false]),
1029
- );
1030
- if (month) return month;
1031
- return 1;
1032
- },
1033
- },
1034
- {
1035
- key: "extractDate",
1036
- value: function extractDate(dateString, format) {
1037
- const date = this.extract.apply(
1038
- this,
1039
- Array.prototype.slice.call(arguments).concat(["dd", false]),
1040
- );
1041
- if (date) return date;
1042
- return 1;
1043
- },
1044
- },
1045
- {
1046
- key: "extractHours",
1047
- value: function extractHours(dateString, format) {
1048
- const hours = this.extract.apply(
1049
- this,
1050
- Array.prototype.slice.call(arguments).concat(["hh"]),
1051
- );
1052
- if (hours) return hours;
1053
- return 0;
1054
- },
1055
- },
1056
- {
1057
- key: "extractMinutes",
1058
- value: function extractMinutes(dateString, format) {
1059
- const minutes = this.extract.apply(
1060
- this,
1061
- Array.prototype.slice.call(arguments).concat(["MM", false]),
1062
- );
1063
- if (minutes) return minutes;
1064
- return 0;
1065
- },
1066
- },
1067
- {
1068
- key: "extractSeconds",
1069
- value: function extractSeconds(dateString, format) {
1070
- const seconds = this.extract.apply(
1071
- this,
1072
- Array.prototype.slice.call(arguments).concat(["ss", false]),
1073
- );
1074
- if (seconds) return seconds;
1075
- return 0;
1076
- },
1077
- },
1078
- {
1079
- key: "extractMilliseconds",
1080
- value: function extractMilliseconds(dateString, format) {
1081
- const milliseconds = this.extract.apply(
1082
- this,
1083
- Array.prototype.slice.call(arguments).concat(["SS", false]),
1084
- );
1085
- if (milliseconds) return milliseconds;
1086
- return 0;
1087
- },
1088
- },
1089
- ]);
1090
-
1091
- return StringDateParser;
1092
- })();
1093
-
1094
- exports.default = StringDateParser;
1095
- },
1096
- {},
1097
- ],
1098
- 6: [
1099
- function (require, module, exports) {
1100
- (function (global) {
1101
- "use strict";
1102
-
1103
- Object.defineProperty(exports, "__esModule", {
1104
- value: true,
1105
- });
1106
-
1107
- const _typeof =
1108
- typeof Symbol === "function" && typeof Symbol.iterator === "symbol"
1109
- ? function (obj) {
1110
- return typeof obj;
1111
- }
1112
- : function (obj) {
1113
- return obj &&
1114
- typeof Symbol === "function" &&
1115
- obj.constructor === Symbol &&
1116
- obj !== Symbol.prototype
1117
- ? "symbol"
1118
- : typeof obj;
1119
- };
1120
-
1121
- const _safe = require("./safe");
1122
-
1123
- const _safe2 = _interopRequireDefault(_safe);
1124
-
1125
- function _interopRequireDefault(obj) {
1126
- return obj && obj.__esModule ? obj : { default: obj };
1127
- }
1128
-
1129
- const globalScope = (function () {
1130
- if (
1131
- (typeof window === "undefined"
1132
- ? "undefined"
1133
- : _typeof(window)) === "object"
1134
- ) {
1135
- return window;
1136
- }
1137
- if (
1138
- (typeof global === "undefined"
1139
- ? "undefined"
1140
- : _typeof(global)) === "object"
1141
- ) {
1142
- return global;
1143
- }
1144
- return {};
1145
- })();
1146
-
1147
- globalScope.HijriDate = _safe2.default;
1148
-
1149
- Date.prototype.toHijri = function () {
1150
- return (0, _safe.toHijri)(this);
1151
- };
1152
-
1153
- exports.default = _safe2.default;
1154
- }).call(
1155
- this,
1156
- typeof global !== "undefined"
1157
- ? global
1158
- : typeof self !== "undefined"
1159
- ? self
1160
- : typeof window !== "undefined"
1161
- ? window
1162
- : {},
1163
- );
1164
- },
1165
- { "./safe": 9 },
1166
- ],
1167
- 7: [
1168
- function (require, module, exports) {
1169
- "use strict";
1170
-
1171
- Object.defineProperty(exports, "__esModule", {
1172
- value: true,
1173
- });
1174
-
1175
- const _createClass = (function () {
1176
- function defineProperties(target, props) {
1177
- for (let i = 0; i < props.length; i++) {
1178
- const descriptor = props[i];
1179
- descriptor.enumerable = descriptor.enumerable || false;
1180
- descriptor.configurable = true;
1181
- if ("value" in descriptor) descriptor.writable = true;
1182
- Object.defineProperty(target, descriptor.key, descriptor);
1183
- }
1184
- }
1185
- return function (Constructor, protoProps, staticProps) {
1186
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
1187
- if (staticProps) defineProperties(Constructor, staticProps);
1188
- return Constructor;
1189
- };
1190
- })();
1191
-
1192
- const _DateConverter = require("./DateConverter");
1193
-
1194
- const _StringDateParser = require("./StringDateParser");
1195
-
1196
- const _StringDateParser2 = _interopRequireDefault(_StringDateParser);
1197
-
1198
- function _interopRequireDefault(obj) {
1199
- return obj && obj.__esModule ? obj : { default: obj };
1200
- }
1201
-
1202
- function _classCallCheck(instance, Constructor) {
1203
- if (!(instance instanceof Constructor)) {
1204
- throw new TypeError("Cannot call a class as a function");
1205
- }
1206
- }
1207
-
1208
- const defaultFormat = "yyyy/mm/dd";
1209
- const defaultProps = {
1210
- month: 1,
1211
- date: 1,
1212
- hours: 0,
1213
- minutes: 0,
1214
- seconds: 0,
1215
- milliseconds: 0,
1216
- };
1217
-
1218
- const Initializer = (function () {
1219
- function Initializer() {
1220
- _classCallCheck(this, Initializer);
1221
- }
1222
-
1223
- _createClass(Initializer, null, [
1224
- {
1225
- key: "initDefault",
1226
- value: function initDefault() {
1227
- return (0, _DateConverter.GregToHijri)(new Date());
1228
- },
1229
- },
1230
- {
1231
- key: "init_number",
1232
- value: function init_number(number) {
1233
- return (0, _DateConverter.GregToHijri)(new Date(number));
1234
- },
1235
- },
1236
- {
1237
- key: "init_number_number",
1238
- value: function init_number_number(year, month) {
1239
- return this.init_number_number_number(year, month, 1);
1240
- },
1241
- },
1242
- {
1243
- key: "init_number_number_number",
1244
- value: function init_number_number_number() {
1245
- return this.initFromNumbers.apply(this, arguments);
1246
- },
1247
- },
1248
- {
1249
- key: "init_number_number_number_number",
1250
- value: function init_number_number_number_number() {
1251
- return this.initFromNumbers.apply(this, arguments);
1252
- },
1253
- },
1254
- {
1255
- key: "init_number_number_number_number_number",
1256
- value: function init_number_number_number_number_number() {
1257
- return this.initFromNumbers.apply(this, arguments);
1258
- },
1259
- },
1260
- {
1261
- key: "init_number_number_number_number_number_number",
1262
- value: function init_number_number_number_number_number_number() {
1263
- return this.initFromNumbers.apply(this, arguments);
1264
- },
1265
- },
1266
- {
1267
- key: "init_number_number_number_number_number_number_number",
1268
- value:
1269
- function init_number_number_number_number_number_number_number() {
1270
- return this.initFromNumbers.apply(this, arguments);
1271
- },
1272
- },
1273
- {
1274
- key: "init_string",
1275
- value: function init_string() {
1276
- return this.initFromStrings.apply(this, arguments);
1277
- },
1278
- },
1279
- {
1280
- key: "init_string_string",
1281
- value: function init_string_string() {
1282
- return this.initFromStrings.apply(this, arguments);
1283
- },
1284
- },
1285
- {
1286
- key: "init_object",
1287
- value: function init_object(object) {
1288
- return Object.assign({}, defaultProps, object);
1289
- },
1290
- },
1291
- {
1292
- key: "initFromNumbers",
1293
- value: function initFromNumbers(year, month, date) {
1294
- const hours =
1295
- arguments.length > 3 && arguments[3] !== undefined
1296
- ? arguments[3]
1297
- : 0;
1298
- const minutes =
1299
- arguments.length > 4 && arguments[4] !== undefined
1300
- ? arguments[4]
1301
- : 0;
1302
- const _arguments = arguments;
1303
- const seconds =
1304
- arguments.length > 5 && arguments[5] !== undefined
1305
- ? arguments[5]
1306
- : 0;
1307
- const milliseconds =
1308
- arguments.length > 6 && arguments[6] !== undefined
1309
- ? arguments[6]
1310
- : 0;
1311
-
1312
- Array.from(arguments).forEach(function (arg, index) {
1313
- _arguments[index] = parseInt(arg);
1314
- });
1315
-
1316
- return {
1317
- year,
1318
- month,
1319
- date,
1320
- hours,
1321
- minutes,
1322
- seconds,
1323
- milliseconds,
1324
- };
1325
- },
1326
- },
1327
- {
1328
- key: "initFromStrings",
1329
- value: function initFromStrings(dateString) {
1330
- const format =
1331
- arguments.length > 1 && arguments[1] !== undefined
1332
- ? arguments[1]
1333
- : defaultFormat;
1334
-
1335
- const props = {};
1336
- props.year = _StringDateParser2.default.extractYear(
1337
- dateString,
1338
- format,
1339
- );
1340
- props.month = _StringDateParser2.default.extractMonth(
1341
- dateString,
1342
- format,
1343
- );
1344
- props.date = _StringDateParser2.default.extractDate(
1345
- dateString,
1346
- format,
1347
- );
1348
- return Object.assign({}, defaultProps, props);
1349
- },
1350
- },
1351
- ]);
1352
-
1353
- return Initializer;
1354
- })();
1355
-
1356
- Initializer.defaultFormat = defaultFormat;
1357
-
1358
- exports.default = Initializer;
1359
- },
1360
- { "./DateConverter": 2, "./StringDateParser": 5 },
1361
- ],
1362
- 8: [
1363
- function (require, module, exports) {
1364
- "use strict";
1365
-
1366
- Object.defineProperty(exports, "__esModule", {
1367
- value: true,
1368
- });
1369
- const ar = (exports.ar = {
1370
- dayNames: [
1371
- "ح",
1372
- "ن",
1373
- "ث",
1374
- "ر",
1375
- "خ",
1376
- "ج",
1377
- "س",
1378
- "أحد",
1379
- "اثن",
1380
- "ثلا",
1381
- "ارب",
1382
- "خم",
1383
- "جم",
1384
- "سبت",
1385
- "الأحد",
1386
- "الإثنين",
1387
- "الثلاثاء",
1388
- "الإربعاء",
1389
- "الخميس",
1390
- "الجمعة",
1391
- "السبت",
1392
- ],
1393
- monthNames: [
1394
- "مح",
1395
- "صف",
1396
- "ربع١",
1397
- "ربع٢",
1398
- "جم١",
1399
- "جم٢",
1400
- "رجب",
1401
- "شعب",
1402
- "رمض",
1403
- "شو",
1404
- "ذو ق",
1405
- "ذو ح",
1406
- "محرّم",
1407
- "صفر",
1408
- "ربيع أول",
1409
- "ربيع الآخر",
1410
- "جمادى أولى",
1411
- "جمادى الآخرة",
1412
- "رجب",
1413
- "شعبان",
1414
- "رمضان",
1415
- "شوال",
1416
- "ذو القعدة",
1417
- "ذو الحجّة",
1418
- ],
1419
- separator: "عند",
1420
- am: "ص",
1421
- pm: "م",
1422
- });
1423
-
1424
- const en = (exports.en = {
1425
- dayNames: [
1426
- "Su",
1427
- "Mo",
1428
- "Tu",
1429
- "We",
1430
- "Th",
1431
- "Fr",
1432
- "Sa",
1433
- "Sun",
1434
- "Mon",
1435
- "Tue",
1436
- "Wed",
1437
- "Thu",
1438
- "Fri",
1439
- "Sat",
1440
- "Sunday",
1441
- "Monday",
1442
- "Tuesday",
1443
- "Wednesday",
1444
- "Thursday",
1445
- "Friday",
1446
- "Saturday",
1447
- ],
1448
- monthNames: [
1449
- "Muha",
1450
- "Saf",
1451
- "Rab1",
1452
- "Rab2",
1453
- "Jumd1",
1454
- "Jumd2",
1455
- "Rajb",
1456
- "Shbn",
1457
- "Rmdn",
1458
- "Shwl",
1459
- "Qada",
1460
- "Hija",
1461
- "Muharram",
1462
- "Safar",
1463
- "Rabi' awwal",
1464
- "Rabi' thani",
1465
- "Jumada' ula",
1466
- "Jumada' thani",
1467
- "Rajab",
1468
- "Sha'aban",
1469
- "Ramadan",
1470
- "Shawwal",
1471
- "Dhul qa'dah",
1472
- "Dhul hijjah",
1473
- ],
1474
- separator: "at",
1475
- am: "am",
1476
- pm: "pm",
1477
- });
1478
- },
1479
- {},
1480
- ],
1481
- 9: [
1482
- function (require, module, exports) {
1483
- "use strict";
1484
-
1485
- Object.defineProperty(exports, "__esModule", {
1486
- value: true,
1487
- });
1488
- exports.toHijri = undefined;
1489
-
1490
- const _HijriDate = require("./HijriDate");
1491
-
1492
- const _HijriDate2 = _interopRequireDefault(_HijriDate);
1493
-
1494
- const _DateConverter = require("./DateConverter");
1495
-
1496
- function _interopRequireDefault(obj) {
1497
- return obj && obj.__esModule ? obj : { default: obj };
1498
- }
1499
-
1500
- exports.fromHijri = function fromHijri(hijriDate) {
1501
- const _HijriToGreg = (0, _DateConverter.HijriToGreg)(hijriDate);
1502
- const year = _HijriToGreg.year;
1503
- const month = _HijriToGreg.month;
1504
- const date = _HijriToGreg.date;
9
+ if (typeof global === 'object') {
10
+ return global;
11
+ }
12
+ return {};
13
+ })();
1505
14
 
1506
- return new Date(
1507
- year,
1508
- month,
1509
- date,
1510
- gregDate.getHours(),
1511
- gregDate.getMinutes(),
1512
- gregDate.getSeconds(),
1513
- gregDate.getMilliseconds(),
1514
- );
1515
- };
15
+ globalScope.HijriDate = HijriDate;
1516
16
 
1517
- exports.toHijri = function toHijri(gregDate) {
1518
- const _GregToHijri = (0, _DateConverter.GregToHijri)(gregDate);
1519
- const year = _GregToHijri.year;
1520
- const month = _GregToHijri.month;
1521
- const date = _GregToHijri.date;
17
+ Date.prototype.toHijri = function() {
18
+ return toHijri(this);
19
+ };
1522
20
 
1523
- return new _HijriDate2.default(
1524
- year,
1525
- month,
1526
- date,
1527
- gregDate.getHours(),
1528
- gregDate.getMinutes(),
1529
- gregDate.getSeconds(),
1530
- gregDate.getMilliseconds(),
1531
- );
1532
- };
1533
- exports.default = _HijriDate2.default;
1534
- },
1535
- { "./DateConverter": 2, "./HijriDate": 4 },
1536
- ],
1537
- },
1538
- {},
1539
- [1],
1540
- );
21
+ export default HijriDate;