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

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