@react-fabric/date 1.0.0-beta.4 → 1.0.0-beta.40
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.
- package/README.md +2 -9
- package/{src/components/Date.module.css → css/_date.css} +5 -5
- package/{src/superdate/SuperDate.module.css → css/styles.css} +2 -8
- package/dist/cjs/components/DatePage.js +2 -3
- package/dist/cjs/components/TimeSliders.js +5 -6
- package/dist/cjs/display/DateDisplay.js +5 -1
- package/dist/cjs/hijri/DateConverter.js +154 -0
- package/dist/cjs/hijri/FormatDate.js +115 -0
- package/dist/cjs/hijri/HijriDate.js +531 -0
- package/dist/cjs/hijri/StringDateParser.js +74 -0
- package/dist/cjs/hijri/index.js +17 -1025
- package/dist/cjs/hijri/initializer.js +113 -0
- package/dist/cjs/hijri/locales.js +19 -0
- package/dist/cjs/hijri/safe.js +17 -0
- package/dist/cjs/i18n/index.js +0 -6
- package/dist/cjs/index.js +11 -2
- package/dist/cjs/{superdate → panels}/EventPanel.js +16 -4
- package/dist/cjs/utils/dateUtil.js +3 -3
- package/dist/esm/components/DatePage.js +2 -3
- package/dist/esm/components/TimeSliders.js +5 -6
- package/dist/esm/display/DateDisplay.js +5 -1
- package/dist/esm/hijri/DateConverter.js +152 -0
- package/dist/esm/hijri/FormatDate.js +112 -0
- package/dist/esm/hijri/HijriDate.js +528 -0
- package/dist/esm/hijri/StringDateParser.js +74 -0
- package/dist/esm/hijri/index.js +17 -1025
- package/dist/esm/hijri/initializer.js +113 -0
- package/dist/esm/hijri/locales.js +18 -0
- package/dist/esm/hijri/safe.js +14 -0
- package/dist/esm/i18n/index.js +0 -6
- package/dist/esm/index.js +5 -1
- package/dist/esm/{superdate → panels}/EventPanel.js +17 -5
- package/dist/esm/utils/dateUtil.js +3 -3
- package/dist/types/display/DateDisplay.d.ts +2 -1
- package/dist/types/hijri/DateConverter.d.ts +13 -0
- package/dist/types/hijri/FormatDate.d.ts +19 -0
- package/dist/types/hijri/HijriDate.d.ts +214 -0
- package/dist/types/hijri/StringDateParser.d.ts +11 -0
- package/dist/types/hijri/index.d.ts +2 -2
- package/dist/types/hijri/initializer.d.ts +129 -0
- package/dist/types/hijri/locales.d.ts +19 -0
- package/dist/types/hijri/safe.d.ts +3 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/panels/EventPanel.d.ts +17 -0
- package/dist/types/types/index.d.ts +8 -35
- package/dist/types/utils/dateUtil.d.ts +1 -1
- package/package.json +8 -8
- package/src/components/DatePage.tsx +2 -3
- package/src/components/TimeSliders.tsx +5 -6
- package/src/display/DateDisplay.tsx +5 -1
- package/src/hijri/DateConverter.js +175 -0
- package/src/hijri/FormatDate.js +132 -0
- package/src/hijri/HijriDate.js +477 -0
- package/src/hijri/StringDateParser.js +68 -0
- package/src/hijri/index.js +16 -1535
- package/src/hijri/initializer.js +96 -0
- package/src/hijri/locales.js +109 -0
- package/src/hijri/safe.js +16 -0
- package/src/i18n/index.ts +0 -3
- package/src/index.ts +6 -1
- package/src/{superdate → panels}/EventPanel.tsx +41 -6
- package/src/types/index.ts +8 -38
- package/src/utils/dateUtil.ts +4 -7
- package/dist/cjs/components/Date.module.css +0 -1
- package/dist/cjs/i18n/superdate/ar.json.js +0 -86
- package/dist/cjs/i18n/superdate/en.json.js +0 -93
- package/dist/cjs/superdate/QuickSelect.js +0 -134
- package/dist/cjs/superdate/RelativeInput.js +0 -79
- package/dist/cjs/superdate/RelativePanel.js +0 -91
- package/dist/cjs/superdate/SuperDate.module.css +0 -1
- package/dist/cjs/superdate/Superdate.js +0 -169
- package/dist/esm/components/Date.module.css +0 -1
- package/dist/esm/i18n/superdate/ar.json.js +0 -79
- package/dist/esm/i18n/superdate/en.json.js +0 -85
- package/dist/esm/superdate/QuickSelect.js +0 -134
- package/dist/esm/superdate/RelativeInput.js +0 -79
- package/dist/esm/superdate/RelativePanel.js +0 -91
- package/dist/esm/superdate/SuperDate.module.css +0 -1
- package/dist/esm/superdate/Superdate.js +0 -168
- package/dist/types/superdate/EventPanel.d.ts +0 -4
- package/dist/types/superdate/QuickSelect.d.ts +0 -1
- package/dist/types/superdate/RelativeInput.d.ts +0 -1
- package/dist/types/superdate/RelativePanel.d.ts +0 -1
- package/dist/types/superdate/Superdate.d.ts +0 -17
- package/src/i18n/superdate/ar.json +0 -70
- package/src/i18n/superdate/en.json +0 -75
- package/src/superdate/QuickSelect.tsx +0 -121
- package/src/superdate/RelativeInput.tsx +0 -64
- package/src/superdate/RelativePanel.tsx +0 -103
- package/src/superdate/Superdate.tsx +0 -186
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
4
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
5
|
+
import { GregToHijri } from './DateConverter.js';
|
|
6
|
+
import StringDateParser from './StringDateParser.js';
|
|
7
|
+
|
|
8
|
+
var defaultFormat = 'yyyy/mm/dd';
|
|
9
|
+
var defaultProps = {
|
|
10
|
+
month: 1,
|
|
11
|
+
date: 1,
|
|
12
|
+
hours: 0,
|
|
13
|
+
minutes: 0,
|
|
14
|
+
seconds: 0,
|
|
15
|
+
milliseconds: 0
|
|
16
|
+
};
|
|
17
|
+
var Initializer = /*#__PURE__*/function () {
|
|
18
|
+
function Initializer() {
|
|
19
|
+
_classCallCheck(this, Initializer);
|
|
20
|
+
}
|
|
21
|
+
return _createClass(Initializer, null, [{
|
|
22
|
+
key: "initDefault",
|
|
23
|
+
value: function initDefault() {
|
|
24
|
+
return GregToHijri(new Date());
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
key: "init_number",
|
|
28
|
+
value: function init_number(number) {
|
|
29
|
+
return GregToHijri(new Date(number));
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
key: "init_number_number",
|
|
33
|
+
value: function init_number_number(year, month) {
|
|
34
|
+
return this.init_number_number_number(year, month, 1);
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "init_number_number_number",
|
|
38
|
+
value: function init_number_number_number() {
|
|
39
|
+
return this.initFromNumbers.apply(this, arguments);
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "init_number_number_number_number",
|
|
43
|
+
value: function init_number_number_number_number() {
|
|
44
|
+
return this.initFromNumbers.apply(this, arguments);
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "init_number_number_number_number_number",
|
|
48
|
+
value: function init_number_number_number_number_number() {
|
|
49
|
+
return this.initFromNumbers.apply(this, arguments);
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "init_number_number_number_number_number_number",
|
|
53
|
+
value: function init_number_number_number_number_number_number() {
|
|
54
|
+
return this.initFromNumbers.apply(this, arguments);
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "init_number_number_number_number_number_number_number",
|
|
58
|
+
value: function init_number_number_number_number_number_number_number() {
|
|
59
|
+
return this.initFromNumbers.apply(this, arguments);
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "init_string",
|
|
63
|
+
value: function init_string() {
|
|
64
|
+
return this.initFromStrings.apply(this, arguments);
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "init_string_string",
|
|
68
|
+
value: function init_string_string() {
|
|
69
|
+
return this.initFromStrings.apply(this, arguments);
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "init_object",
|
|
73
|
+
value: function init_object(object) {
|
|
74
|
+
return Object.assign({}, defaultProps, object);
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "initFromNumbers",
|
|
78
|
+
value: function initFromNumbers(year, month, date) {
|
|
79
|
+
var _arguments = arguments;
|
|
80
|
+
var hours = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
81
|
+
var minutes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
82
|
+
var seconds = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
83
|
+
var milliseconds = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
|
|
84
|
+
Array.from(arguments).forEach(function (arg, index) {
|
|
85
|
+
_arguments[index] = parseInt(arg);
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
year: year,
|
|
89
|
+
month: month,
|
|
90
|
+
date: date,
|
|
91
|
+
hours: hours,
|
|
92
|
+
minutes: minutes,
|
|
93
|
+
seconds: seconds,
|
|
94
|
+
milliseconds: milliseconds
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//TODO
|
|
99
|
+
}, {
|
|
100
|
+
key: "initFromStrings",
|
|
101
|
+
value: function initFromStrings(dateString) {
|
|
102
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultFormat;
|
|
103
|
+
var props = {};
|
|
104
|
+
props.year = StringDateParser.extractYear(dateString, format);
|
|
105
|
+
props.month = StringDateParser.extractMonth(dateString, format);
|
|
106
|
+
props.date = StringDateParser.extractDate(dateString, format);
|
|
107
|
+
return Object.assign({}, defaultProps, props);
|
|
108
|
+
}
|
|
109
|
+
}]);
|
|
110
|
+
}();
|
|
111
|
+
Initializer.defaultFormat = defaultFormat;
|
|
112
|
+
|
|
113
|
+
export { Initializer as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
var ar = {
|
|
4
|
+
dayNames: ["ح", "ن", "ث", "ر", "خ", "ج", "س", "أحد", "اثن", "ثلا", "ارب", "خم", "جم", "سبت", "الأحد", "الإثنين", "الثلاثاء", "الإربعاء", "الخميس", "الجمعة", "السبت"],
|
|
5
|
+
monthNames: ["مح", "صف", "ربع١", "ربع٢", "جم١", "جم٢", "رجب", "شعب", "رمض", "شو", "ذو ق", "ذو ح", "محرّم", "صفر", "ربيع أول", "ربيع الآخر", "جمادى أولى", "جمادى الآخرة", "رجب", "شعبان", "رمضان", "شوال", "ذو القعدة", "ذو الحجّة"],
|
|
6
|
+
separator: "عند",
|
|
7
|
+
am: "ص",
|
|
8
|
+
pm: "م"
|
|
9
|
+
};
|
|
10
|
+
var en = {
|
|
11
|
+
dayNames: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
|
12
|
+
monthNames: ["Muha", "Saf", "Rab1", "Rab2", "Jumd1", "Jumd2", "Rajb", "Shbn", "Rmdn", "Shwl", "Qada", "Hija", "Muharram", "Safar", "Rabi'ul Awwal", "Rabi'ul Akhir", "Jumadal Ula", "Jumadal Akhira", "Rajab", "Sha'ban", "Ramadan", "Shawwal", "Dhul Qa'ada", "Dhul Hijja"],
|
|
13
|
+
separator: "at",
|
|
14
|
+
am: "am",
|
|
15
|
+
pm: "pm"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { ar, en };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import HijriDate from './HijriDate.js';
|
|
4
|
+
import { GregToHijri } from './DateConverter.js';
|
|
5
|
+
|
|
6
|
+
var toHijri = function toHijri(gregDate) {
|
|
7
|
+
var _GregToHijri = GregToHijri(gregDate),
|
|
8
|
+
year = _GregToHijri.year,
|
|
9
|
+
month = _GregToHijri.month,
|
|
10
|
+
date = _GregToHijri.date;
|
|
11
|
+
return new HijriDate(year, month, date, gregDate.getHours(), gregDate.getMinutes(), gregDate.getSeconds(), gregDate.getMilliseconds());
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { HijriDate as default, toHijri };
|
package/dist/esm/i18n/index.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
import { addTranslationBundle } from '@react-fabric/core';
|
|
4
4
|
import ar from './ar.json.js';
|
|
5
5
|
import en from './en.json.js';
|
|
6
|
-
import arSuper from './superdate/ar.json.js';
|
|
7
|
-
import enSuper from './superdate/en.json.js';
|
|
8
6
|
|
|
9
7
|
/*
|
|
10
8
|
* React Fabric
|
|
@@ -33,7 +31,3 @@ addTranslationBundle("date", {
|
|
|
33
31
|
en: en,
|
|
34
32
|
ar: ar
|
|
35
33
|
});
|
|
36
|
-
addTranslationBundle("superdate", {
|
|
37
|
-
en: enSuper,
|
|
38
|
-
ar: arSuper
|
|
39
|
-
});
|
package/dist/esm/index.js
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import './hijri/index.js';
|
|
4
4
|
import './i18n/index.js';
|
|
5
|
+
export { DateHeader } from './components/DateHeader.js';
|
|
6
|
+
export { DecadePage } from './components/DecadePage.js';
|
|
7
|
+
export { YearPage } from './components/YearPage.js';
|
|
5
8
|
export { DateDisplay } from './display/DateDisplay.js';
|
|
6
9
|
export { DatePanel } from './panels/DatePanel.js';
|
|
10
|
+
export { EventPanel } from './panels/EventPanel.js';
|
|
7
11
|
export { RangePanel } from './panels/RangePanel.js';
|
|
8
|
-
export { SuperDate } from './superdate/Superdate.js';
|
|
9
12
|
export { DateUtil } from './utils/dateUtil.js';
|
|
13
|
+
export { DatePart, PageType } from './types/index.js';
|
|
@@ -5,7 +5,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
5
5
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
6
6
|
import { Section, Content } from '@react-fabric/core';
|
|
7
7
|
import { EMPTY_ARRAY } from '@react-fabric/utilities';
|
|
8
|
-
import { startOfDay, endOfDay, isSameMonth } from 'date-fns';
|
|
8
|
+
import { startOfDay, endOfDay, isSameMonth, setYear } from 'date-fns';
|
|
9
9
|
import i18next from 'i18next';
|
|
10
10
|
import { useState, useReducer, useEffect } from 'react';
|
|
11
11
|
import { useTranslation } from 'react-i18next';
|
|
@@ -19,8 +19,18 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
19
19
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
20
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
21
|
var makeList = function makeList(year) {
|
|
22
|
-
var
|
|
22
|
+
var recurring = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
23
|
+
var predefined = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
23
24
|
var list = _toConsumableArray(predefined);
|
|
25
|
+
recurring.forEach(function (evt) {
|
|
26
|
+
return list.push({
|
|
27
|
+
label: evt.label,
|
|
28
|
+
hijri: evt.hijri,
|
|
29
|
+
icon: evt.icon,
|
|
30
|
+
start: setYear(DateUtil.parseDate(evt.start), year),
|
|
31
|
+
end: setYear(DateUtil.parseDate(evt.end), year)
|
|
32
|
+
});
|
|
33
|
+
});
|
|
24
34
|
list.push({
|
|
25
35
|
label: "superdate:event.newYear",
|
|
26
36
|
start: startOfDay(new Date("".concat(year - 1, "-12-31"))),
|
|
@@ -51,7 +61,9 @@ var EventPanel = function EventPanel(_ref) {
|
|
|
51
61
|
var isHijri = _ref.isHijri,
|
|
52
62
|
onChange = _ref.onChange,
|
|
53
63
|
_ref$events = _ref.events,
|
|
54
|
-
events = _ref$events === void 0 ? EMPTY_ARRAY : _ref$events
|
|
64
|
+
events = _ref$events === void 0 ? EMPTY_ARRAY : _ref$events,
|
|
65
|
+
_ref$recurringEvents = _ref.recurringEvents,
|
|
66
|
+
recurringEvents = _ref$recurringEvents === void 0 ? EMPTY_ARRAY : _ref$recurringEvents;
|
|
55
67
|
var _useTranslation = useTranslation(),
|
|
56
68
|
t = _useTranslation.t;
|
|
57
69
|
var _useState = useState({}),
|
|
@@ -70,14 +82,14 @@ var EventPanel = function EventPanel(_ref) {
|
|
|
70
82
|
if (action.type === "changePageDate") {
|
|
71
83
|
resetList = true;
|
|
72
84
|
state.pageDate = action.date;
|
|
73
|
-
if (action.changePage
|
|
85
|
+
if (action.changePage) {
|
|
74
86
|
state.page = Math.max(state.page - 1, PageType.MONTH);
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
89
|
if (resetList) {
|
|
78
90
|
var _predefined$year;
|
|
79
91
|
var year = state.pageDate.getFullYear();
|
|
80
|
-
state.events = makeList(year, (_predefined$year = predefined[year]) !== null && _predefined$year !== void 0 ? _predefined$year : []);
|
|
92
|
+
state.events = makeList(year, recurringEvents !== null && recurringEvents !== void 0 ? recurringEvents : [], (_predefined$year = predefined[year]) !== null && _predefined$year !== void 0 ? _predefined$year : []);
|
|
81
93
|
}
|
|
82
94
|
return _objectSpread({}, state);
|
|
83
95
|
}, {
|
|
@@ -81,7 +81,7 @@ var DateUtil;
|
|
|
81
81
|
return formatted;
|
|
82
82
|
};
|
|
83
83
|
var isRelative = _DateUtil.isRelative = function (date) {
|
|
84
|
-
return isString(date) && date.match(/^(\$\w+)([+-])(\d+)?$/) !== null;
|
|
84
|
+
return isString(date) && date.match(/^(\$\w+)([+-])?(\d+)?$/) !== null;
|
|
85
85
|
};
|
|
86
86
|
_DateUtil.isRelativeRange = function (date) {
|
|
87
87
|
return isString(date) && date.match(/^(\$\w+)([+-])(\d+)?\|(\$\w+)([+-])(\d+)?$/) !== null;
|
|
@@ -375,6 +375,7 @@ var DateUtil;
|
|
|
375
375
|
};
|
|
376
376
|
var _parse = function _parse(dt, rounded) {
|
|
377
377
|
var _dt$match2;
|
|
378
|
+
if (!isRelative(dt)) return new Date(dt);
|
|
378
379
|
var _ref3 = (_dt$match2 = dt.match(/^(\$\w+)([+-]\d+)?$/)) !== null && _dt$match2 !== void 0 ? _dt$match2 : [],
|
|
379
380
|
_ref4 = _slicedToArray(_ref3, 3),
|
|
380
381
|
part = _ref4[1],
|
|
@@ -432,7 +433,6 @@ var DateUtil;
|
|
|
432
433
|
}
|
|
433
434
|
return new Date(dt);
|
|
434
435
|
};
|
|
435
|
-
})(DateUtil || (DateUtil = {}));
|
|
436
|
-
window.DateUtil = DateUtil;
|
|
436
|
+
})(DateUtil || (DateUtil = {}));
|
|
437
437
|
|
|
438
438
|
export { DateUtil };
|
|
@@ -11,5 +11,6 @@ export interface Props extends CssProp, AriaProps, TestProps, Partial<ChildrenPr
|
|
|
11
11
|
* date format
|
|
12
12
|
*/
|
|
13
13
|
format?: string;
|
|
14
|
+
showAlternateDate?: boolean;
|
|
14
15
|
}
|
|
15
|
-
export declare const DateDisplay: ({ date, className, format, children, ...aria }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const DateDisplay: ({ date, className, format, children, showAlternateDate, ...aria }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function weekDay(wdn: any): "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun" | "";
|
|
2
|
+
export function GregToHijri(gregDate: any): {
|
|
3
|
+
year: number;
|
|
4
|
+
month: number;
|
|
5
|
+
date: number;
|
|
6
|
+
hours: any;
|
|
7
|
+
minutes: any;
|
|
8
|
+
seconds: any;
|
|
9
|
+
milliseconds: any;
|
|
10
|
+
day: number;
|
|
11
|
+
dayName: string;
|
|
12
|
+
};
|
|
13
|
+
export function HijriToGreg(hijriDate: any): Date;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export namespace masks {
|
|
2
|
+
let _default: string;
|
|
3
|
+
export { _default as default };
|
|
4
|
+
export let shortDate: string;
|
|
5
|
+
export let mediumDate: string;
|
|
6
|
+
export let longDate: string;
|
|
7
|
+
export let fullDate: string;
|
|
8
|
+
export let shortTime: string;
|
|
9
|
+
export let mediumTime: string;
|
|
10
|
+
export let longTime: string;
|
|
11
|
+
export let isoDate: string;
|
|
12
|
+
export let isoTime: string;
|
|
13
|
+
export let isoDateTime: string;
|
|
14
|
+
export let isoUtcDateTime: string;
|
|
15
|
+
}
|
|
16
|
+
export default dateFormat;
|
|
17
|
+
declare function dateFormat(date: any, mask: any, options?: {
|
|
18
|
+
utc: boolean;
|
|
19
|
+
}, ...args: any[]): any;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
export const dateProps: string[];
|
|
2
|
+
export default HijriDate;
|
|
3
|
+
/**
|
|
4
|
+
The class which handles Hijri 🌙 instances
|
|
5
|
+
|
|
6
|
+
@example new HijriDate(); //now
|
|
7
|
+
new HijriDate(1438, 12, 10) ; // يوم عيد الأضحى لسنة ١٤٣٨
|
|
8
|
+
new HijriDate(1438,7, 20, 18, 50, 44, 333); // Monday Rajab 20 1438 18:50:44
|
|
9
|
+
new HijriDate({year:1355, hours:17}); // Tue Muharram 01 1355 17:00:00
|
|
10
|
+
new HijriDate(1484408713014);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
new HijriDate().toGregorian(); // === new Date();
|
|
14
|
+
new Date().toHijri(); // === new HijriDate();
|
|
15
|
+
*/
|
|
16
|
+
declare class HijriDate {
|
|
17
|
+
static now(): number;
|
|
18
|
+
static today(): HijriDate;
|
|
19
|
+
static yesterday(): HijriDate;
|
|
20
|
+
static tomorrow(): HijriDate;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @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)
|
|
24
|
+
* @example new HijriDate(1435454346342) // Sunday Ramadan 12 1436 04:19:06
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @param {number} year the hijri year .
|
|
28
|
+
* @param {number} month [1, 12] range .
|
|
29
|
+
* @param {number} [date=1] the date of the month🌔 ∈ {1, 30} .
|
|
30
|
+
* @param {number} [hours=0] ⏰ ∈ {0, 23} .
|
|
31
|
+
* @param {number} [minutes=0] 🕔 ∈ {0,59} .
|
|
32
|
+
* @param {number} [seconds=0] 🕰 ∈ {0,59} .
|
|
33
|
+
* @param {number} [milliseconds 0] 🕰 ∈ {0,999} .
|
|
34
|
+
*
|
|
35
|
+
* @example new HijriDate(1450, 3) ; //Sun Rabee1 01 1450 00:00:00
|
|
36
|
+
new HijriDate(1450, 3, 5) ; //Thu Rabee1 05 1450 00:00:00
|
|
37
|
+
new HijriDate(1450, 3, 5, 17) ; //Thu Rabee1 05 1450 17:00:00
|
|
38
|
+
new HijriDate(1450, 3, 5, 16, 44) ; //Thu Rabee1 05 1450 16:44:00
|
|
39
|
+
new HijriDate(1450, 3, 5, 16, 44, 58) ; //Thu Rabee1 05 1450 16:44:58
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} date stringified date
|
|
43
|
+
* @param {string} [format = 'yyyy/mm/dd'] a compatible format with the date passed as string in the 1ˢᵗ argument.
|
|
44
|
+
* @example new HijriDate('10-09-1538', 'dd-mm-yyyy'); // Thu Rmdn 10 1538 00:00:00
|
|
45
|
+
new HijriDate('100 years since 04-1348','100 years since mm-yyyy' ); // Wed Rab2 01 1338 00:00:00
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @param {Object} dateProps literal object contains date properties .
|
|
49
|
+
* @param {number} dateProps.year the year is required .
|
|
50
|
+
* @param {number} [dateProps.month = 1] [1, 12] range .
|
|
51
|
+
* @param {number} [dateProps.date = 1] the date of the month🌔 ∈ {1, 30} .
|
|
52
|
+
* @param {number} [dateProps.hours = 0] ⏰ ∈ {0, 23} .
|
|
53
|
+
* @param {number} [dateProps.minutes = 0] 🕔 ∈ {0,59} .
|
|
54
|
+
* @param {number} [dateProps.seconds = 0] 🕰 ∈ {0,59} .
|
|
55
|
+
* @param {number} [dateProps.milliseconds = 0] 🕰 ∈ {0,999} .
|
|
56
|
+
*
|
|
57
|
+
* @example new HijriDate({year: 1430, minutes: 54}) // 01-01-1430 00:54:00
|
|
58
|
+
new HijriDate({year: 1504, hours: 17, seconds:44}) // 01-01-1504 17:00:44
|
|
59
|
+
*/
|
|
60
|
+
constructor(...args: any[]);
|
|
61
|
+
init(...args: any[]): this;
|
|
62
|
+
__proxy__: any;
|
|
63
|
+
initDayOfWeek(): void;
|
|
64
|
+
_day: any;
|
|
65
|
+
_dayName: any;
|
|
66
|
+
/**
|
|
67
|
+
* Set the year
|
|
68
|
+
* @param {number} newYear year modifier of the instance.
|
|
69
|
+
* @returns {undefined} nothing
|
|
70
|
+
*
|
|
71
|
+
* @example const d1 = new HijriDate(1399, 10, 25);
|
|
72
|
+
d1.year += 2;
|
|
73
|
+
assertEqual(d1.year === 1401);
|
|
74
|
+
*/
|
|
75
|
+
set year(newYear: number);
|
|
76
|
+
/**
|
|
77
|
+
* Get the year
|
|
78
|
+
* @returns {number} the year
|
|
79
|
+
*/
|
|
80
|
+
get year(): number;
|
|
81
|
+
_year: number | undefined;
|
|
82
|
+
set month(newMonth: any);
|
|
83
|
+
get month(): any;
|
|
84
|
+
_month: any;
|
|
85
|
+
set date(newDate: any);
|
|
86
|
+
get date(): any;
|
|
87
|
+
_date: any;
|
|
88
|
+
set time(newTime: any);
|
|
89
|
+
get time(): any;
|
|
90
|
+
set hours(hours: any);
|
|
91
|
+
get hours(): any;
|
|
92
|
+
set minutes(minutes: any);
|
|
93
|
+
get minutes(): any;
|
|
94
|
+
set seconds(seconds: any);
|
|
95
|
+
get seconds(): any;
|
|
96
|
+
set milliseconds(milliseconds: any);
|
|
97
|
+
get milliseconds(): any;
|
|
98
|
+
get timezoneOffset(): any;
|
|
99
|
+
_hours: any;
|
|
100
|
+
_minutes: any;
|
|
101
|
+
_seconds: any;
|
|
102
|
+
_milliseconds: any;
|
|
103
|
+
get day(): any;
|
|
104
|
+
get dayName(): any;
|
|
105
|
+
getFullYear(): number;
|
|
106
|
+
getMonthIndex(): number;
|
|
107
|
+
getMonth(): any;
|
|
108
|
+
getDate(): any;
|
|
109
|
+
getDay(): any;
|
|
110
|
+
getHours(): any;
|
|
111
|
+
getMinutes(): any;
|
|
112
|
+
getSeconds(): any;
|
|
113
|
+
getMilliseconds(): any;
|
|
114
|
+
getTime(): any;
|
|
115
|
+
getTimezoneOffset(): any;
|
|
116
|
+
/**
|
|
117
|
+
* This method adds 1 day (24 hours) to the instance.
|
|
118
|
+
* @returns {HijriDate} the instance itself after adding 1 day.
|
|
119
|
+
*/
|
|
120
|
+
addDay(): HijriDate;
|
|
121
|
+
/**
|
|
122
|
+
* This method adds n day(s) to the instance.
|
|
123
|
+
* @param {number} days number of days to add .
|
|
124
|
+
* @returns {HijriDate} the instance itself after adding n day(s).
|
|
125
|
+
*/
|
|
126
|
+
addDays(days: number): HijriDate;
|
|
127
|
+
/**
|
|
128
|
+
* TODO
|
|
129
|
+
*/
|
|
130
|
+
addHours(n: any): this;
|
|
131
|
+
/**
|
|
132
|
+
* TODO
|
|
133
|
+
*/
|
|
134
|
+
addMinutes(n: any): this;
|
|
135
|
+
/**
|
|
136
|
+
* TODO
|
|
137
|
+
*/
|
|
138
|
+
addSeconds(n: any): this;
|
|
139
|
+
/**
|
|
140
|
+
* TODO
|
|
141
|
+
*/
|
|
142
|
+
addMilliseconds(n: any): this;
|
|
143
|
+
/**
|
|
144
|
+
* TODO
|
|
145
|
+
*/
|
|
146
|
+
subtractDays(days: any): this;
|
|
147
|
+
/**
|
|
148
|
+
* TODO
|
|
149
|
+
*/
|
|
150
|
+
subtractDay(): this;
|
|
151
|
+
/**
|
|
152
|
+
* TODO
|
|
153
|
+
*/
|
|
154
|
+
subtractHours(n: any): this;
|
|
155
|
+
/**
|
|
156
|
+
* TODO
|
|
157
|
+
*/
|
|
158
|
+
subtractMinutes(n: any): this;
|
|
159
|
+
/**
|
|
160
|
+
* TODO
|
|
161
|
+
*/
|
|
162
|
+
subtractSeconds(n: any): this;
|
|
163
|
+
/**
|
|
164
|
+
* TODO
|
|
165
|
+
*/
|
|
166
|
+
subtractMilliseconds(n: any): this;
|
|
167
|
+
/**
|
|
168
|
+
* TODO
|
|
169
|
+
*/
|
|
170
|
+
updateProxy(): this;
|
|
171
|
+
/**
|
|
172
|
+
* TODO
|
|
173
|
+
*/
|
|
174
|
+
toGregorian(): any;
|
|
175
|
+
/**
|
|
176
|
+
* TODO
|
|
177
|
+
*/
|
|
178
|
+
format(mask: any, options: any, ...args: any[]): any;
|
|
179
|
+
/**
|
|
180
|
+
* TODO
|
|
181
|
+
*/
|
|
182
|
+
ignoreTime(): this;
|
|
183
|
+
/**
|
|
184
|
+
* TODO
|
|
185
|
+
*/
|
|
186
|
+
clone(): HijriDate;
|
|
187
|
+
/**
|
|
188
|
+
* TODO
|
|
189
|
+
*/
|
|
190
|
+
is(...args: any[]): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* TODO
|
|
193
|
+
*/
|
|
194
|
+
isToday(): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* TODO
|
|
197
|
+
*/
|
|
198
|
+
isYesterday(): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* TODO
|
|
201
|
+
*/
|
|
202
|
+
isTomorrow(): boolean;
|
|
203
|
+
valueOf(): any;
|
|
204
|
+
toString(): any;
|
|
205
|
+
}
|
|
206
|
+
declare namespace HijriDate {
|
|
207
|
+
namespace locales {
|
|
208
|
+
export { ar };
|
|
209
|
+
export { en };
|
|
210
|
+
}
|
|
211
|
+
let defaultLocale: string;
|
|
212
|
+
}
|
|
213
|
+
import { ar } from './locales';
|
|
214
|
+
import { en } from './locales';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default StringDateParser;
|
|
2
|
+
declare class StringDateParser {
|
|
3
|
+
static extract(string: any, format: any, formatChunk: any, ignoreCase?: boolean): number | undefined;
|
|
4
|
+
static extractYear(dateString: any, format: any, ...args: any[]): number | undefined;
|
|
5
|
+
static extractMonth(dateString: any, format: any, ...args: any[]): number;
|
|
6
|
+
static extractDate(dateString: any, format: any, ...args: any[]): number;
|
|
7
|
+
static extractHours(dateString: any, format: any, ...args: any[]): number;
|
|
8
|
+
static extractMinutes(dateString: any, format: any, ...args: any[]): number;
|
|
9
|
+
static extractSeconds(dateString: any, format: any, ...args: any[]): number;
|
|
10
|
+
static extractMilliseconds(dateString: any, format: any, ...args: any[]): number;
|
|
11
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export default HijriDate;
|
|
2
|
+
import HijriDate from './safe';
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export default Initializer;
|
|
2
|
+
declare class Initializer {
|
|
3
|
+
static initDefault(): {
|
|
4
|
+
year: number;
|
|
5
|
+
month: number;
|
|
6
|
+
date: number;
|
|
7
|
+
hours: any;
|
|
8
|
+
minutes: any;
|
|
9
|
+
seconds: any;
|
|
10
|
+
milliseconds: any;
|
|
11
|
+
day: number;
|
|
12
|
+
dayName: string;
|
|
13
|
+
};
|
|
14
|
+
static init_number(number: any): {
|
|
15
|
+
year: number;
|
|
16
|
+
month: number;
|
|
17
|
+
date: number;
|
|
18
|
+
hours: any;
|
|
19
|
+
minutes: any;
|
|
20
|
+
seconds: any;
|
|
21
|
+
milliseconds: any;
|
|
22
|
+
day: number;
|
|
23
|
+
dayName: string;
|
|
24
|
+
};
|
|
25
|
+
static init_number_number(year: any, month: any): {
|
|
26
|
+
year: any;
|
|
27
|
+
month: any;
|
|
28
|
+
date: any;
|
|
29
|
+
hours: number;
|
|
30
|
+
minutes: number;
|
|
31
|
+
seconds: number;
|
|
32
|
+
milliseconds: number;
|
|
33
|
+
};
|
|
34
|
+
static init_number_number_number(...args: any[]): {
|
|
35
|
+
year: any;
|
|
36
|
+
month: any;
|
|
37
|
+
date: any;
|
|
38
|
+
hours: number;
|
|
39
|
+
minutes: number;
|
|
40
|
+
seconds: number;
|
|
41
|
+
milliseconds: number;
|
|
42
|
+
};
|
|
43
|
+
static init_number_number_number_number(...args: any[]): {
|
|
44
|
+
year: any;
|
|
45
|
+
month: any;
|
|
46
|
+
date: any;
|
|
47
|
+
hours: number;
|
|
48
|
+
minutes: number;
|
|
49
|
+
seconds: number;
|
|
50
|
+
milliseconds: number;
|
|
51
|
+
};
|
|
52
|
+
static init_number_number_number_number_number(...args: any[]): {
|
|
53
|
+
year: any;
|
|
54
|
+
month: any;
|
|
55
|
+
date: any;
|
|
56
|
+
hours: number;
|
|
57
|
+
minutes: number;
|
|
58
|
+
seconds: number;
|
|
59
|
+
milliseconds: number;
|
|
60
|
+
};
|
|
61
|
+
static init_number_number_number_number_number_number(...args: any[]): {
|
|
62
|
+
year: any;
|
|
63
|
+
month: any;
|
|
64
|
+
date: any;
|
|
65
|
+
hours: number;
|
|
66
|
+
minutes: number;
|
|
67
|
+
seconds: number;
|
|
68
|
+
milliseconds: number;
|
|
69
|
+
};
|
|
70
|
+
static init_number_number_number_number_number_number_number(...args: any[]): {
|
|
71
|
+
year: any;
|
|
72
|
+
month: any;
|
|
73
|
+
date: any;
|
|
74
|
+
hours: number;
|
|
75
|
+
minutes: number;
|
|
76
|
+
seconds: number;
|
|
77
|
+
milliseconds: number;
|
|
78
|
+
};
|
|
79
|
+
static init_string(...args: any[]): {
|
|
80
|
+
month: number;
|
|
81
|
+
date: number;
|
|
82
|
+
hours: number;
|
|
83
|
+
minutes: number;
|
|
84
|
+
seconds: number;
|
|
85
|
+
milliseconds: number;
|
|
86
|
+
} & {
|
|
87
|
+
year: number | undefined;
|
|
88
|
+
month: number;
|
|
89
|
+
date: number;
|
|
90
|
+
};
|
|
91
|
+
static init_string_string(...args: any[]): {
|
|
92
|
+
month: number;
|
|
93
|
+
date: number;
|
|
94
|
+
hours: number;
|
|
95
|
+
minutes: number;
|
|
96
|
+
seconds: number;
|
|
97
|
+
milliseconds: number;
|
|
98
|
+
} & {
|
|
99
|
+
year: number | undefined;
|
|
100
|
+
month: number;
|
|
101
|
+
date: number;
|
|
102
|
+
};
|
|
103
|
+
static init_object(object: any): any;
|
|
104
|
+
static initFromNumbers(year: any, month: any, date: any, hours?: number, minutes?: number, seconds?: number, milliseconds?: number, ...args: any[]): {
|
|
105
|
+
year: any;
|
|
106
|
+
month: any;
|
|
107
|
+
date: any;
|
|
108
|
+
hours: number;
|
|
109
|
+
minutes: number;
|
|
110
|
+
seconds: number;
|
|
111
|
+
milliseconds: number;
|
|
112
|
+
};
|
|
113
|
+
static initFromStrings(dateString: any, format?: string): {
|
|
114
|
+
month: number;
|
|
115
|
+
date: number;
|
|
116
|
+
hours: number;
|
|
117
|
+
minutes: number;
|
|
118
|
+
seconds: number;
|
|
119
|
+
milliseconds: number;
|
|
120
|
+
} & {
|
|
121
|
+
year: number | undefined;
|
|
122
|
+
month: number;
|
|
123
|
+
date: number;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
declare namespace Initializer {
|
|
127
|
+
export { defaultFormat };
|
|
128
|
+
}
|
|
129
|
+
declare const defaultFormat: "yyyy/mm/dd";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export namespace ar {
|
|
2
|
+
let dayNames: string[];
|
|
3
|
+
let monthNames: string[];
|
|
4
|
+
let separator: string;
|
|
5
|
+
let am: string;
|
|
6
|
+
let pm: string;
|
|
7
|
+
}
|
|
8
|
+
export namespace en {
|
|
9
|
+
let dayNames_1: string[];
|
|
10
|
+
export { dayNames_1 as dayNames };
|
|
11
|
+
let monthNames_1: string[];
|
|
12
|
+
export { monthNames_1 as monthNames };
|
|
13
|
+
let separator_1: string;
|
|
14
|
+
export { separator_1 as separator };
|
|
15
|
+
let am_1: string;
|
|
16
|
+
export { am_1 as am };
|
|
17
|
+
let pm_1: string;
|
|
18
|
+
export { pm_1 as pm };
|
|
19
|
+
}
|