@react-fabric/date 1.0.0-beta.6 → 1.0.0-beta.60

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 (110) 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/DateHeader.js +16 -8
  5. package/dist/cjs/components/DatePage.js +2 -3
  6. package/dist/cjs/components/TimeSliders.js +5 -6
  7. package/dist/cjs/display/DateDisplay.js +24 -2
  8. package/dist/cjs/display/DateDuration.js +143 -0
  9. package/dist/cjs/hijri/DateConverter.js +154 -0
  10. package/dist/cjs/hijri/FormatDate.js +116 -0
  11. package/dist/cjs/hijri/HijriDate.js +531 -0
  12. package/dist/cjs/hijri/StringDateParser.js +74 -0
  13. package/dist/cjs/hijri/index.js +17 -1025
  14. package/dist/cjs/hijri/initializer.js +113 -0
  15. package/dist/cjs/hijri/locales.js +19 -0
  16. package/dist/cjs/hijri/safe.js +17 -0
  17. package/dist/cjs/i18n/ar.json.js +191 -3
  18. package/dist/cjs/i18n/en.json.js +63 -1
  19. package/dist/cjs/i18n/index.js +0 -6
  20. package/dist/cjs/index.js +13 -2
  21. package/dist/cjs/panels/DatePanel.js +26 -0
  22. package/dist/cjs/{superdate → panels}/EventPanel.js +2 -1
  23. package/dist/cjs/panels/RangePanel.js +23 -0
  24. package/dist/cjs/utils/dateUtil.js +1 -4
  25. package/dist/esm/components/DateHeader.js +16 -8
  26. package/dist/esm/components/DatePage.js +2 -3
  27. package/dist/esm/components/TimeSliders.js +5 -6
  28. package/dist/esm/display/DateDisplay.js +24 -2
  29. package/dist/esm/display/DateDuration.js +143 -0
  30. package/dist/esm/hijri/DateConverter.js +152 -0
  31. package/dist/esm/hijri/FormatDate.js +113 -0
  32. package/dist/esm/hijri/HijriDate.js +528 -0
  33. package/dist/esm/hijri/StringDateParser.js +74 -0
  34. package/dist/esm/hijri/index.js +17 -1025
  35. package/dist/esm/hijri/initializer.js +113 -0
  36. package/dist/esm/hijri/locales.js +18 -0
  37. package/dist/esm/hijri/safe.js +14 -0
  38. package/dist/esm/i18n/ar.json.js +191 -3
  39. package/dist/esm/i18n/en.json.js +63 -2
  40. package/dist/esm/i18n/index.js +0 -6
  41. package/dist/esm/index.js +6 -1
  42. package/dist/esm/panels/DatePanel.js +26 -0
  43. package/dist/esm/{superdate → panels}/EventPanel.js +2 -1
  44. package/dist/esm/panels/RangePanel.js +23 -0
  45. package/dist/esm/utils/dateUtil.js +1 -4
  46. package/dist/types/display/DateDisplay.d.ts +21 -3
  47. package/dist/types/display/DateDuration.d.ts +31 -0
  48. package/dist/types/hijri/DateConverter.d.ts +13 -0
  49. package/dist/types/hijri/FormatDate.d.ts +19 -0
  50. package/dist/types/hijri/HijriDate.d.ts +214 -0
  51. package/dist/types/hijri/StringDateParser.d.ts +11 -0
  52. package/dist/types/hijri/index.d.ts +2 -2
  53. package/dist/types/hijri/initializer.d.ts +129 -0
  54. package/dist/types/hijri/locales.d.ts +19 -0
  55. package/dist/types/hijri/safe.d.ts +3 -0
  56. package/dist/types/index.d.ts +6 -1
  57. package/dist/types/panels/DatePanel.d.ts +26 -0
  58. package/dist/types/panels/EventPanel.d.ts +17 -0
  59. package/dist/types/panels/RangePanel.d.ts +22 -0
  60. package/dist/types/types/index.d.ts +8 -40
  61. package/package.json +13 -16
  62. package/src/components/DateHeader.tsx +4 -8
  63. package/src/components/DatePage.tsx +2 -3
  64. package/src/components/TimeSliders.tsx +5 -6
  65. package/src/display/DateDisplay.tsx +32 -4
  66. package/src/display/DateDuration.tsx +180 -0
  67. package/src/hijri/DateConverter.js +175 -0
  68. package/src/hijri/FormatDate.js +134 -0
  69. package/src/hijri/HijriDate.js +477 -0
  70. package/src/hijri/StringDateParser.js +68 -0
  71. package/src/hijri/index.js +16 -1535
  72. package/src/hijri/initializer.js +96 -0
  73. package/src/hijri/locales.js +109 -0
  74. package/src/hijri/safe.js +16 -0
  75. package/src/i18n/ar.json +190 -1
  76. package/src/i18n/en.json +60 -0
  77. package/src/i18n/index.ts +0 -3
  78. package/src/index.ts +7 -1
  79. package/src/panels/DatePanel.tsx +26 -0
  80. package/src/{superdate → panels}/EventPanel.tsx +21 -3
  81. package/src/panels/RangePanel.tsx +23 -0
  82. package/src/types/index.ts +8 -43
  83. package/src/utils/dateUtil.ts +1 -5
  84. package/dist/cjs/components/Date.module.css +0 -1
  85. package/dist/cjs/i18n/superdate/ar.json.js +0 -86
  86. package/dist/cjs/i18n/superdate/en.json.js +0 -93
  87. package/dist/cjs/superdate/QuickSelect.js +0 -134
  88. package/dist/cjs/superdate/RelativeInput.js +0 -79
  89. package/dist/cjs/superdate/RelativePanel.js +0 -91
  90. package/dist/cjs/superdate/SuperDate.module.css +0 -1
  91. package/dist/cjs/superdate/Superdate.js +0 -177
  92. package/dist/esm/components/Date.module.css +0 -1
  93. package/dist/esm/i18n/superdate/ar.json.js +0 -79
  94. package/dist/esm/i18n/superdate/en.json.js +0 -85
  95. package/dist/esm/superdate/QuickSelect.js +0 -134
  96. package/dist/esm/superdate/RelativeInput.js +0 -79
  97. package/dist/esm/superdate/RelativePanel.js +0 -91
  98. package/dist/esm/superdate/SuperDate.module.css +0 -1
  99. package/dist/esm/superdate/Superdate.js +0 -176
  100. package/dist/types/superdate/EventPanel.d.ts +0 -4
  101. package/dist/types/superdate/QuickSelect.d.ts +0 -1
  102. package/dist/types/superdate/RelativeInput.d.ts +0 -1
  103. package/dist/types/superdate/RelativePanel.d.ts +0 -1
  104. package/dist/types/superdate/Superdate.d.ts +0 -17
  105. package/src/i18n/superdate/ar.json +0 -70
  106. package/src/i18n/superdate/en.json +0 -75
  107. package/src/superdate/QuickSelect.tsx +0 -121
  108. package/src/superdate/RelativeInput.tsx +0 -64
  109. package/src/superdate/RelativePanel.tsx +0 -103
  110. package/src/superdate/Superdate.tsx +0 -198
@@ -0,0 +1,531 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _typeof = require('@babel/runtime/helpers/typeof');
6
+ var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
7
+ var _createClass = require('@babel/runtime/helpers/createClass');
8
+ var DateConverter = require('./DateConverter.js');
9
+ var initializer = require('./initializer.js');
10
+ var FormatDate = require('./FormatDate.js');
11
+ var locales = require('./locales.js');
12
+
13
+ /**
14
+ The class which handles Hijri 🌙 instances
15
+
16
+ @example new HijriDate(); //now
17
+ new HijriDate(1438, 12, 10) ; // يوم عيد الأضحى لسنة ١٤٣٨
18
+ new HijriDate(1438,7, 20, 18, 50, 44, 333); // Monday Rajab 20 1438 18:50:44
19
+ new HijriDate({year:1355, hours:17}); // Tue Muharram 01 1355 17:00:00
20
+ new HijriDate(1484408713014);
21
+
22
+
23
+ new HijriDate().toGregorian(); // === new Date();
24
+ new Date().toHijri(); // === new HijriDate();
25
+ */
26
+ var HijriDate = /*#__PURE__*/function () {
27
+ /**
28
+ *
29
+ * @param {number} time numeric value of the specified date as the number of milliseconds since Shawwal 23, 1389, 00:00:00 UTC (January 1, 1970, 00:00:00 UTC)
30
+ * @example new HijriDate(1435454346342) // Sunday Ramadan 12 1436 04:19:06
31
+ */
32
+
33
+ /**
34
+ * @param {number} year the hijri year .
35
+ * @param {number} month [1, 12] range .
36
+ * @param {number} [date=1] the date of the month🌔 ∈ {1, 30} .
37
+ * @param {number} [hours=0] ⏰ ∈ {0, 23} .
38
+ * @param {number} [minutes=0] 🕔 ∈ {0,59} .
39
+ * @param {number} [seconds=0] 🕰 ∈ {0,59} .
40
+ * @param {number} [milliseconds 0] 🕰 ∈ {0,999} .
41
+ *
42
+ * @example new HijriDate(1450, 3) ; //Sun Rabee1 01 1450 00:00:00
43
+ new HijriDate(1450, 3, 5) ; //Thu Rabee1 05 1450 00:00:00
44
+ new HijriDate(1450, 3, 5, 17) ; //Thu Rabee1 05 1450 17:00:00
45
+ new HijriDate(1450, 3, 5, 16, 44) ; //Thu Rabee1 05 1450 16:44:00
46
+ new HijriDate(1450, 3, 5, 16, 44, 58) ; //Thu Rabee1 05 1450 16:44:58
47
+ */
48
+
49
+ /**
50
+ * @param {string} date stringified date
51
+ * @param {string} [format = 'yyyy/mm/dd'] a compatible format with the date passed as string in the 1ˢᵗ argument.
52
+ * @example new HijriDate('10-09-1538', 'dd-mm-yyyy'); // Thu Rmdn 10 1538 00:00:00
53
+ new HijriDate('100 years since 04-1348','100 years since mm-yyyy' ); // Wed Rab2 01 1338 00:00:00
54
+ */
55
+ /**
56
+ * @param {Object} dateProps literal object contains date properties .
57
+ * @param {number} dateProps.year the year is required .
58
+ * @param {number} [dateProps.month = 1] [1, 12] range .
59
+ * @param {number} [dateProps.date = 1] the date of the month🌔 ∈ {1, 30} .
60
+ * @param {number} [dateProps.hours = 0] ⏰ ∈ {0, 23} .
61
+ * @param {number} [dateProps.minutes = 0] 🕔 ∈ {0,59} .
62
+ * @param {number} [dateProps.seconds = 0] 🕰 ∈ {0,59} .
63
+ * @param {number} [dateProps.milliseconds = 0] 🕰 ∈ {0,999} .
64
+ *
65
+ * @example new HijriDate({year: 1430, minutes: 54}) // 01-01-1430 00:54:00
66
+ new HijriDate({year: 1504, hours: 17, seconds:44}) // 01-01-1504 17:00:44
67
+ */
68
+ function HijriDate() {
69
+ _classCallCheck(this, HijriDate);
70
+ return this.init.apply(this, arguments);
71
+ }
72
+ return _createClass(HijriDate, [{
73
+ key: "init",
74
+ value: function init() {
75
+ var _this = this;
76
+ var props = {};
77
+ if (!arguments.length) {
78
+ props = initializer.initDefault();
79
+ } else {
80
+ try {
81
+ var methodNameSuffix = Array.from(arguments).map(function (arg) {
82
+ return _typeof(arg);
83
+ }).join('_');
84
+ props = initializer['init_' + methodNameSuffix].apply(initializer, arguments);
85
+ } catch (e) {
86
+ throw new TypeError(hijriTypeErrorMessage + '\n--- Details:\n' + e);
87
+ }
88
+ }
89
+ Object.keys(props).forEach(function (prop) {
90
+ _this['_' + prop] = props[prop];
91
+ });
92
+ this.__proxy__ = DateConverter.HijriToGreg(this);
93
+ this.initDayOfWeek();
94
+ return this;
95
+ }
96
+ }, {
97
+ key: "initDayOfWeek",
98
+ value: function initDayOfWeek() {
99
+ if (!this.__proxy__) return;
100
+ this._day = this._day || this.__proxy__.getDay();
101
+ this._dayName = this._dayName || DateConverter.weekDay(this._day);
102
+ }
103
+ /**
104
+ * Get the year
105
+ * @returns {number} the year
106
+ */
107
+ }, {
108
+ key: "year",
109
+ get: function get() {
110
+ return this._year;
111
+ }
112
+
113
+ /**
114
+ * Set the year
115
+ * @param {number} newYear year modifier of the instance.
116
+ * @returns {undefined} nothing
117
+ *
118
+ * @example const d1 = new HijriDate(1399, 10, 25);
119
+ d1.year += 2;
120
+ assertEqual(d1.year === 1401);
121
+ */,
122
+ set: function set(newYear) {
123
+ this._year = newYear;
124
+ this.updateProxy();
125
+ }
126
+ }, {
127
+ key: "month",
128
+ get: function get() {
129
+ return this._month;
130
+ },
131
+ set: function set(newMonth) {
132
+ this._month = newMonth;
133
+ this.updateProxy();
134
+ }
135
+ }, {
136
+ key: "date",
137
+ get: function get() {
138
+ return this._date;
139
+ },
140
+ set: function set(newDate) {
141
+ this._date = newDate;
142
+ this.updateProxy();
143
+ }
144
+ //---time getters and setters
145
+ }, {
146
+ key: "time",
147
+ get: function get() {
148
+ return this.__proxy__.getTime();
149
+ },
150
+ set: function set(newTime) {
151
+ var _this2 = this;
152
+ var props = initializer.init_number(newTime);
153
+ Object.keys(props).forEach(function (prop) {
154
+ _this2['_' + prop] = props[prop];
155
+ });
156
+ this.__proxy__ = new Date(newTime);
157
+ }
158
+ }, {
159
+ key: "hours",
160
+ get: function get() {
161
+ return this._hours || 0;
162
+ },
163
+ set: function set(hours) {
164
+ this._hours = hours;
165
+ this.updateProxy();
166
+ }
167
+ }, {
168
+ key: "minutes",
169
+ get: function get() {
170
+ return this._minutes || 0;
171
+ },
172
+ set: function set(minutes) {
173
+ this._minutes = minutes;
174
+ this.updateProxy();
175
+ }
176
+ }, {
177
+ key: "seconds",
178
+ get: function get() {
179
+ return this._seconds || 0;
180
+ },
181
+ set: function set(seconds) {
182
+ this._seconds = seconds;
183
+ this.updateProxy();
184
+ }
185
+ }, {
186
+ key: "milliseconds",
187
+ get: function get() {
188
+ return this._milliseconds || 0;
189
+ },
190
+ set: function set(milliseconds) {
191
+ this._milliseconds = milliseconds;
192
+ this.updateProxy();
193
+ }
194
+ }, {
195
+ key: "timezoneOffset",
196
+ get: function get() {
197
+ return this.__proxy__.getTimezoneOffset();
198
+ }
199
+ }, {
200
+ key: "day",
201
+ get: function get() {
202
+ return this._day;
203
+ }
204
+ }, {
205
+ key: "dayName",
206
+ get: function get() {
207
+ return this._dayName;
208
+ }
209
+ }, {
210
+ key: "getFullYear",
211
+ value: function getFullYear() {
212
+ return this.year;
213
+ }
214
+ }, {
215
+ key: "getMonthIndex",
216
+ value: function getMonthIndex() {
217
+ return this.month - 1;
218
+ }
219
+ }, {
220
+ key: "getMonth",
221
+ value: function getMonth() {
222
+ return this.month;
223
+ }
224
+ }, {
225
+ key: "getDate",
226
+ value: function getDate() {
227
+ return this.date;
228
+ }
229
+ }, {
230
+ key: "getDay",
231
+ value: function getDay() {
232
+ return this.day;
233
+ }
234
+ }, {
235
+ key: "getHours",
236
+ value: function getHours() {
237
+ return this.hours;
238
+ }
239
+ }, {
240
+ key: "getMinutes",
241
+ value: function getMinutes() {
242
+ return this.minutes;
243
+ }
244
+ }, {
245
+ key: "getSeconds",
246
+ value: function getSeconds() {
247
+ return this.seconds;
248
+ }
249
+ }, {
250
+ key: "getMilliseconds",
251
+ value: function getMilliseconds() {
252
+ return this.milliseconds;
253
+ }
254
+ }, {
255
+ key: "getTime",
256
+ value: function getTime() {
257
+ return this.time;
258
+ }
259
+ }, {
260
+ key: "getTimezoneOffset",
261
+ value: function getTimezoneOffset() {
262
+ return this.timezoneOffset;
263
+ }
264
+
265
+ /**
266
+ * This method adds 1 day (24 hours) to the instance.
267
+ * @returns {HijriDate} the instance itself after adding 1 day.
268
+ */
269
+ }, {
270
+ key: "addDay",
271
+ value: function addDay() {
272
+ return this.addHours(24);
273
+ }
274
+ /**
275
+ * This method adds n day(s) to the instance.
276
+ * @param {number} days number of days to add .
277
+ * @returns {HijriDate} the instance itself after adding n day(s).
278
+ */
279
+ }, {
280
+ key: "addDays",
281
+ value: function addDays(days) {
282
+ var _this3 = this;
283
+ if (typeof days === 'number') Array.from({
284
+ length: days
285
+ }, function (v, k) {
286
+ return k + 1;
287
+ }).forEach(function (i) {
288
+ return _this3.addDay();
289
+ });
290
+ return this;
291
+ }
292
+ /**
293
+ * TODO
294
+ */
295
+ }, {
296
+ key: "addHours",
297
+ value: function addHours(n) {
298
+ return this.addMinutes(n * 60);
299
+ }
300
+
301
+ /**
302
+ * TODO
303
+ */
304
+ }, {
305
+ key: "addMinutes",
306
+ value: function addMinutes(n) {
307
+ return this.addSeconds(n * 60);
308
+ }
309
+
310
+ /**
311
+ * TODO
312
+ */
313
+ }, {
314
+ key: "addSeconds",
315
+ value: function addSeconds(n) {
316
+ return this.addMilliseconds(1000 * n);
317
+ }
318
+
319
+ /**
320
+ * TODO
321
+ */
322
+ }, {
323
+ key: "addMilliseconds",
324
+ value: function addMilliseconds(n) {
325
+ this.time += n;
326
+ return this;
327
+ }
328
+
329
+ /**
330
+ * TODO
331
+ */
332
+ }, {
333
+ key: "subtractDays",
334
+ value: function subtractDays(days) {
335
+ var _this4 = this;
336
+ Array.from({
337
+ length: days
338
+ }, function (v, k) {
339
+ return k + 1;
340
+ }).forEach(function (i) {
341
+ return _this4.subtractDay();
342
+ });
343
+ return this;
344
+ }
345
+
346
+ /**
347
+ * TODO
348
+ */
349
+ }, {
350
+ key: "subtractDay",
351
+ value: function subtractDay() {
352
+ return this.subtractHours(24);
353
+ }
354
+
355
+ /**
356
+ * TODO
357
+ */
358
+ }, {
359
+ key: "subtractHours",
360
+ value: function subtractHours(n) {
361
+ return this.subtractMinutes(n * 60);
362
+ }
363
+
364
+ /**
365
+ * TODO
366
+ */
367
+ }, {
368
+ key: "subtractMinutes",
369
+ value: function subtractMinutes(n) {
370
+ return this.subtractSeconds(n * 60);
371
+ }
372
+
373
+ /**
374
+ * TODO
375
+ */
376
+ }, {
377
+ key: "subtractSeconds",
378
+ value: function subtractSeconds(n) {
379
+ return this.subtractMilliseconds(1000 * n);
380
+ }
381
+
382
+ /**
383
+ * TODO
384
+ */
385
+ }, {
386
+ key: "subtractMilliseconds",
387
+ value: function subtractMilliseconds(n) {
388
+ return this.addMilliseconds(-n);
389
+ }
390
+
391
+ /**
392
+ * TODO
393
+ */
394
+ }, {
395
+ key: "updateProxy",
396
+ value: function updateProxy() {
397
+ this.__proxy__ = DateConverter.HijriToGreg(this);
398
+ return this;
399
+ }
400
+
401
+ /**
402
+ * TODO
403
+ */
404
+ }, {
405
+ key: "toGregorian",
406
+ value: function toGregorian() {
407
+ return this.__proxy__;
408
+ }
409
+
410
+ /**
411
+ * TODO
412
+ */
413
+ }, {
414
+ key: "format",
415
+ value: function format(mask, options) {
416
+ return FormatDate.default.apply(void 0, [this].concat(Array.prototype.slice.call(arguments)));
417
+ }
418
+
419
+ /**
420
+ * TODO
421
+ */
422
+ }, {
423
+ key: "ignoreTime",
424
+ value: function ignoreTime() {
425
+ this.hours = 0;
426
+ this.minutes = 0;
427
+ this.seconds = 0;
428
+ this.milliseconds = 0;
429
+ this.updateProxy();
430
+ return this;
431
+ }
432
+
433
+ /**
434
+ * TODO
435
+ */
436
+ }, {
437
+ key: "clone",
438
+ value: function clone() {
439
+ return new HijriDate(this.time);
440
+ }
441
+
442
+ /**
443
+ * TODO
444
+ */
445
+ }, {
446
+ key: "is",
447
+ value: function is() {
448
+ var _arguments = arguments,
449
+ _this5 = this;
450
+ if (!arguments.length) throw new Error("function cannot be called without arguments");
451
+ if (arguments.length === 1 && _typeof(arguments[0]) === 'object' && Object.keys(arguments[0]).length) return Object.keys(arguments[0]).every(function (prop) {
452
+ return parseInt(_arguments[0][prop]) === parseInt(_this5[prop]);
453
+ });
454
+ return Array.from(arguments).every(function (arg, i) {
455
+ return arg === _this5[dateProps[i]];
456
+ });
457
+ }
458
+
459
+ /**
460
+ * TODO
461
+ */
462
+ }, {
463
+ key: "isToday",
464
+ value: function isToday() {
465
+ return HijriDate.today().time == this.clone().ignoreTime().time;
466
+ }
467
+
468
+ /**
469
+ * TODO
470
+ */
471
+ }, {
472
+ key: "isYesterday",
473
+ value: function isYesterday() {
474
+ return HijriDate.yesterday().time == this.clone().ignoreTime().time;
475
+ }
476
+
477
+ /**
478
+ * TODO
479
+ */
480
+ }, {
481
+ key: "isTomorrow",
482
+ value: function isTomorrow() {
483
+ return HijriDate.tomorrow().time == this.clone().ignoreTime().time;
484
+ }
485
+ }, {
486
+ key: "valueOf",
487
+ value: function valueOf() {
488
+ return this.getTime();
489
+ }
490
+ }, {
491
+ key: "toString",
492
+ value: function toString() {
493
+ return this.format('default');
494
+ }
495
+ }], [{
496
+ key: "now",
497
+ value: function now() {
498
+ return Date.now();
499
+ }
500
+ }, {
501
+ key: "today",
502
+ value: function today() {
503
+ return new HijriDate().ignoreTime();
504
+ }
505
+ }, {
506
+ key: "yesterday",
507
+ value: function yesterday() {
508
+ return this.today().subtractDay();
509
+ }
510
+ }, {
511
+ key: "tomorrow",
512
+ value: function tomorrow() {
513
+ return this.today().addDay();
514
+ }
515
+
516
+ ////TODO
517
+ // static addDay() {
518
+ //
519
+ // }
520
+ }]);
521
+ }();
522
+ HijriDate.locales = {
523
+ ar: locales.ar,
524
+ en: locales.en
525
+ };
526
+ HijriDate.defaultLocale = 'ar';
527
+ var hijriTypeErrorMessage = "\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 ";
528
+ var dateProps = ['year', 'month', 'date', 'hours', 'minutes', 'seconds', 'milliseconds'];
529
+
530
+ exports.dateProps = dateProps;
531
+ exports.default = HijriDate;
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
4
+ var _createClass = require('@babel/runtime/helpers/createClass');
5
+
6
+ var StringDateParser = /*#__PURE__*/function () {
7
+ function StringDateParser() {
8
+ _classCallCheck(this, StringDateParser);
9
+ }
10
+ return _createClass(StringDateParser, null, [{
11
+ key: "extract",
12
+ value: function extract(string, format, formatChunk) {
13
+ var ignoreCase = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
14
+ var targetFormat = ignoreCase ? format.toLowerCase() : format;
15
+ if (targetFormat.includes(formatChunk)) {
16
+ return parseInt(string.substr(targetFormat.indexOf(formatChunk), formatChunk.length));
17
+ }
18
+ }
19
+ }, {
20
+ key: "extractYear",
21
+ value: function extractYear(dateString, format) {
22
+ var year = this.extract.apply(this, Array.prototype.slice.call(arguments).concat(['yyyy']));
23
+ if (!year) {
24
+ year = this.extract.apply(this, Array.prototype.slice.call(arguments).concat(['yy']));
25
+ if (year) year = Number('14' + year);
26
+ }
27
+ return year;
28
+ }
29
+ }, {
30
+ key: "extractMonth",
31
+ value: function extractMonth(dateString, format) {
32
+ var month = this.extract.apply(this, Array.prototype.slice.call(arguments).concat(['mm', false]));
33
+ if (month) return month;
34
+ return 1;
35
+ }
36
+ }, {
37
+ key: "extractDate",
38
+ value: function extractDate(dateString, format) {
39
+ var date = this.extract.apply(this, Array.prototype.slice.call(arguments).concat(['dd', false]));
40
+ if (date) return date;
41
+ return 1;
42
+ }
43
+ }, {
44
+ key: "extractHours",
45
+ value: function extractHours(dateString, format) {
46
+ var hours = this.extract.apply(this, Array.prototype.slice.call(arguments).concat(['hh']));
47
+ if (hours) return hours;
48
+ return 0;
49
+ }
50
+ }, {
51
+ key: "extractMinutes",
52
+ value: function extractMinutes(dateString, format) {
53
+ var minutes = this.extract.apply(this, Array.prototype.slice.call(arguments).concat(['MM', false]));
54
+ if (minutes) return minutes;
55
+ return 0;
56
+ }
57
+ }, {
58
+ key: "extractSeconds",
59
+ value: function extractSeconds(dateString, format) {
60
+ var seconds = this.extract.apply(this, Array.prototype.slice.call(arguments).concat(['ss', false]));
61
+ if (seconds) return seconds;
62
+ return 0;
63
+ }
64
+ }, {
65
+ key: "extractMilliseconds",
66
+ value: function extractMilliseconds(dateString, format) {
67
+ var milliseconds = this.extract.apply(this, Array.prototype.slice.call(arguments).concat(['SS', false]));
68
+ if (milliseconds) return milliseconds;
69
+ return 0;
70
+ }
71
+ }]);
72
+ }();
73
+
74
+ module.exports = StringDateParser;