@react-fabric/date 1.0.0-beta.5 → 1.0.0-beta.51
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 +7 -2
- package/dist/cjs/display/DateDuration.js +127 -0
- 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/ar.json.js +191 -3
- package/dist/cjs/i18n/en.json.js +63 -1
- package/dist/cjs/i18n/index.js +0 -6
- package/dist/cjs/index.js +13 -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 +7 -2
- package/dist/esm/display/DateDuration.js +127 -0
- 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/ar.json.js +191 -3
- package/dist/esm/i18n/en.json.js +63 -2
- package/dist/esm/i18n/index.js +0 -6
- package/dist/esm/index.js +6 -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 +4 -3
- package/dist/types/display/DateDuration.d.ts +15 -0
- 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 +6 -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 +11 -11
- package/src/components/DatePage.tsx +2 -3
- package/src/components/TimeSliders.tsx +5 -6
- package/src/display/DateDisplay.tsx +15 -4
- package/src/display/DateDuration.tsx +164 -0
- 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/ar.json +190 -1
- package/src/i18n/en.json +60 -0
- package/src/i18n/index.ts +0 -3
- package/src/index.ts +7 -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
package/README.md
CHANGED
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
@layer
|
|
25
|
-
.dateHeader {
|
|
26
|
-
box-shadow: 0 -1px 0
|
|
24
|
+
@layer components {
|
|
25
|
+
.fabric-dateHeader {
|
|
26
|
+
box-shadow: 0 -1px 0 --alpha(var(--color-tint-200) / 50%) inset;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.timeSlider {
|
|
29
|
+
.fabric-date-timeSlider {
|
|
30
30
|
height: 11.25rem;
|
|
31
31
|
|
|
32
32
|
&::before,
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
content: "";
|
|
35
35
|
z-index: 10;
|
|
36
36
|
display: block;
|
|
37
|
-
box-shadow: 0 0 3rem 0.25rem
|
|
37
|
+
box-shadow: 0 0 3rem 0.25rem var(--color-tint-600);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
&::before {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
*
|
|
6
6
|
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c)
|
|
7
|
+
* Copyright (c) 2025 Adarsh Pastakia
|
|
8
8
|
*
|
|
9
9
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
10
|
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
@@ -21,10 +21,4 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
@
|
|
25
|
-
.superDate {
|
|
26
|
-
&:root {
|
|
27
|
-
font-size: 10px;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
24
|
+
@import "./_date.css";
|
|
@@ -9,7 +9,6 @@ var dateUtil = require('../utils/dateUtil.js');
|
|
|
9
9
|
var DateCell = require('./DateCell.js');
|
|
10
10
|
var classNames = require('classnames');
|
|
11
11
|
var index = require('../types/index.js');
|
|
12
|
-
var Date_module = require('./Date.module.css');
|
|
13
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
14
13
|
|
|
15
14
|
var _excluded = ["pageDate", "isHijri"];
|
|
@@ -29,11 +28,11 @@ var DatePage = function DatePage(_ref) {
|
|
|
29
28
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
30
29
|
className: classNames("grid grid-cols-8 area-content", props.page !== index.PageType.DATE && "invisible"),
|
|
31
30
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
32
|
-
className: classNames(
|
|
31
|
+
className: classNames("fabric-dateHeader", "px-1 text-center bg-tint-50 h-7")
|
|
33
32
|
}), cols.map(function (col) {
|
|
34
33
|
var dt = dateUtil.DateUtil.addDays(startDate, col, isHijri);
|
|
35
34
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
36
|
-
className: classNames(
|
|
35
|
+
className: classNames("fabric-dateHeader", "font-medium text-sm p-1 mx-px text-center text-muted bg-tint-50 h-7"),
|
|
37
36
|
children: dateUtil.DateUtil.format(dt, "eeeeee", i18next.language, isHijri)
|
|
38
37
|
}, dt.toISOString());
|
|
39
38
|
}), rows.map(function (row) {
|
|
@@ -4,7 +4,6 @@ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
|
4
4
|
var core = require('@react-fabric/core');
|
|
5
5
|
var classNames = require('classnames');
|
|
6
6
|
var react = require('react');
|
|
7
|
-
var Date_module = require('./Date.module.css');
|
|
8
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
8
|
|
|
10
9
|
var TimeSlider = function TimeSlider(_ref) {
|
|
@@ -58,16 +57,16 @@ var TimeSlider = function TimeSlider(_ref) {
|
|
|
58
57
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
59
58
|
className: "flex",
|
|
60
59
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
61
|
-
className: classNames(
|
|
60
|
+
className: classNames("fabric-dateHeader", "flex-1 font-medium text-muted text-sm p-1 mx-px text-center bg-tint-50"),
|
|
62
61
|
children: "H"
|
|
63
62
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
64
|
-
className: classNames(
|
|
63
|
+
className: classNames("fabric-dateHeader", "flex-1 font-medium text-muted text-sm p-1 mx-px text-center bg-tint-50"),
|
|
65
64
|
children: "M"
|
|
66
65
|
})]
|
|
67
66
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
68
|
-
className: "flex flex-1 flex-nowrap overflow-hidden relative",
|
|
67
|
+
className: "flex flex-1 flex-nowrap items-stretch overflow-hidden relative",
|
|
69
68
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
70
|
-
className: classNames("flex-1 overflow-auto scroll-hide snap-y snap-mandatory",
|
|
69
|
+
className: classNames("flex-1 overflow-auto scroll-hide snap-y snap-mandatory", "fabric-date-timeSlider"),
|
|
71
70
|
onScroll: calculateTime,
|
|
72
71
|
ref: hourRef,
|
|
73
72
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -92,7 +91,7 @@ var TimeSlider = function TimeSlider(_ref) {
|
|
|
92
91
|
className: "w-full"
|
|
93
92
|
})]
|
|
94
93
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
95
|
-
className: classNames("flex-1 overflow-auto scroll-hide snap-y snap-mandatory",
|
|
94
|
+
className: classNames("flex-1 overflow-auto scroll-hide snap-y snap-mandatory", "fabric-date-timeSlider"),
|
|
96
95
|
onScroll: calculateTime,
|
|
97
96
|
ref: minuteRef,
|
|
98
97
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -4,9 +4,10 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
|
4
4
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
5
5
|
var core = require('@react-fabric/core');
|
|
6
6
|
var dateUtil = require('../utils/dateUtil.js');
|
|
7
|
+
var classNames = require('classnames');
|
|
7
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
9
|
|
|
9
|
-
var _excluded = ["date", "className", "format", "children"];
|
|
10
|
+
var _excluded = ["date", "className", "format", "children", "showAlternateDate"];
|
|
10
11
|
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; }
|
|
11
12
|
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; }
|
|
12
13
|
var DateDisplay = function DateDisplay(_ref) {
|
|
@@ -15,19 +16,23 @@ var DateDisplay = function DateDisplay(_ref) {
|
|
|
15
16
|
_ref$format = _ref.format,
|
|
16
17
|
format = _ref$format === void 0 ? "eee, PPpp" : _ref$format,
|
|
17
18
|
children = _ref.children,
|
|
19
|
+
showAlternateDate = _ref.showAlternateDate,
|
|
18
20
|
aria = _objectWithoutProperties(_ref, _excluded);
|
|
19
21
|
var _useGlobals = core.useGlobals(),
|
|
20
22
|
currentCalendar = _useGlobals.currentCalendar,
|
|
21
23
|
currentLocale = _useGlobals.currentLocale;
|
|
22
24
|
var dtLabel = /*#__PURE__*/jsxRuntime.jsx(core.Tooltip, {
|
|
25
|
+
disabled: !showAlternateDate,
|
|
23
26
|
content: dateUtil.DateUtil.format(date, format, currentLocale, currentCalendar !== "hijri"),
|
|
24
27
|
children: /*#__PURE__*/jsxRuntime.jsx("span", _objectSpread(_objectSpread({
|
|
25
|
-
className: className
|
|
28
|
+
className: classNames(className, !!children && "underline decoration-dotted cursor-pointer")
|
|
26
29
|
}, aria), {}, {
|
|
27
30
|
children: dateUtil.DateUtil.format(date, format, currentLocale, currentCalendar === "hijri")
|
|
28
31
|
}))
|
|
29
32
|
});
|
|
30
33
|
return children ? /*#__PURE__*/jsxRuntime.jsxs(core.Dropdown, {
|
|
34
|
+
showArrow: true,
|
|
35
|
+
closeOnClick: true,
|
|
31
36
|
children: [dtLabel, children]
|
|
32
37
|
}) : dtLabel;
|
|
33
38
|
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
5
|
+
var core = require('@react-fabric/core');
|
|
6
|
+
var utilities = require('@react-fabric/utilities');
|
|
7
|
+
var classNames = require('classnames');
|
|
8
|
+
var dateFns = require('date-fns');
|
|
9
|
+
var react = require('react');
|
|
10
|
+
var reactI18next = require('react-i18next');
|
|
11
|
+
var dateUtil = require('../utils/dateUtil.js');
|
|
12
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
+
|
|
14
|
+
var _excluded = ["date", "children", "className", "format"];
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
var DateDuration = function DateDuration(_ref) {
|
|
18
|
+
var date = _ref.date,
|
|
19
|
+
children = _ref.children,
|
|
20
|
+
className = _ref.className,
|
|
21
|
+
_ref$format = _ref.format,
|
|
22
|
+
format = _ref$format === void 0 ? "PPpp" : _ref$format,
|
|
23
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
+
var _useTranslation = reactI18next.useTranslation("date"),
|
|
25
|
+
t = _useTranslation.t;
|
|
26
|
+
var interval = react.useMemo(function () {
|
|
27
|
+
return dateFns.intervalToDuration({
|
|
28
|
+
start: new Date(date),
|
|
29
|
+
end: new Date()
|
|
30
|
+
});
|
|
31
|
+
}, [date]);
|
|
32
|
+
var label = react.useMemo(function () {
|
|
33
|
+
var before = dateFns.isBefore(dateUtil.DateUtil.parseDate(date), new Date());
|
|
34
|
+
var tkey = before ? "relative.before" : "relative.after";
|
|
35
|
+
var part = "now";
|
|
36
|
+
var count = 0;
|
|
37
|
+
if (interval.years && interval.years > 0) {
|
|
38
|
+
var _interval$months;
|
|
39
|
+
part = "years";
|
|
40
|
+
count = interval.years;
|
|
41
|
+
if (((_interval$months = interval.months) !== null && _interval$months !== void 0 ? _interval$months : 0) > 10) {
|
|
42
|
+
part = "yearsX";
|
|
43
|
+
count += 1;
|
|
44
|
+
}
|
|
45
|
+
} else if (interval.months && interval.months > 0) {
|
|
46
|
+
var _interval$weeks;
|
|
47
|
+
part = "months";
|
|
48
|
+
count = interval.months;
|
|
49
|
+
if (interval.months > 10) {
|
|
50
|
+
part = "yearsX";
|
|
51
|
+
count = 1;
|
|
52
|
+
} else if (((_interval$weeks = interval.weeks) !== null && _interval$weeks !== void 0 ? _interval$weeks : 0) > 3) {
|
|
53
|
+
part = "monthsX";
|
|
54
|
+
count += 1;
|
|
55
|
+
}
|
|
56
|
+
} else if (interval.weeks && interval.weeks > 0) {
|
|
57
|
+
var _interval$days;
|
|
58
|
+
part = "weeks";
|
|
59
|
+
count = interval.weeks;
|
|
60
|
+
if (interval.weeks > 3) {
|
|
61
|
+
part = "monthsX";
|
|
62
|
+
count = 1;
|
|
63
|
+
} else if (((_interval$days = interval.days) !== null && _interval$days !== void 0 ? _interval$days : 0) > 5) {
|
|
64
|
+
part = "weeksX";
|
|
65
|
+
count += 1;
|
|
66
|
+
}
|
|
67
|
+
} else if (interval.days && interval.days > 0) {
|
|
68
|
+
var _interval$hours;
|
|
69
|
+
part = "days";
|
|
70
|
+
count = interval.days;
|
|
71
|
+
if (interval.days > 5) {
|
|
72
|
+
part = "weeksX";
|
|
73
|
+
count = 1;
|
|
74
|
+
} else if (((_interval$hours = interval.hours) !== null && _interval$hours !== void 0 ? _interval$hours : 0) > 20) {
|
|
75
|
+
part = "daysX";
|
|
76
|
+
count += 1;
|
|
77
|
+
}
|
|
78
|
+
} else if (interval.hours && interval.hours > 0) {
|
|
79
|
+
var _interval$minutes;
|
|
80
|
+
part = "hours";
|
|
81
|
+
count = interval.hours;
|
|
82
|
+
if (interval.hours > 20) {
|
|
83
|
+
part = "daysX";
|
|
84
|
+
count = 1;
|
|
85
|
+
} else if (((_interval$minutes = interval.minutes) !== null && _interval$minutes !== void 0 ? _interval$minutes : 0) > 45) {
|
|
86
|
+
part = "hoursX";
|
|
87
|
+
count += 1;
|
|
88
|
+
}
|
|
89
|
+
} else if (interval.minutes && interval.minutes > 0) {
|
|
90
|
+
var _interval$seconds;
|
|
91
|
+
part = "minutes";
|
|
92
|
+
count = interval.minutes;
|
|
93
|
+
if (interval.minutes > 45) {
|
|
94
|
+
part = "hoursX";
|
|
95
|
+
count = 1;
|
|
96
|
+
} else if (((_interval$seconds = interval.seconds) !== null && _interval$seconds !== void 0 ? _interval$seconds : 0) > 45) {
|
|
97
|
+
part = "minuteX";
|
|
98
|
+
count += 1;
|
|
99
|
+
}
|
|
100
|
+
} else if (interval.seconds && interval.seconds > 15) {
|
|
101
|
+
part = "seconds";
|
|
102
|
+
count = interval.seconds;
|
|
103
|
+
if (interval.seconds > 45) {
|
|
104
|
+
part = "minutesX";
|
|
105
|
+
count = 1;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return t("".concat(tkey, ".").concat(part), {
|
|
109
|
+
count: count
|
|
110
|
+
});
|
|
111
|
+
}, [interval, date]);
|
|
112
|
+
var dtLabel = /*#__PURE__*/jsxRuntime.jsx(core.Tooltip, {
|
|
113
|
+
content: utilities.Format.date(date, format),
|
|
114
|
+
children: /*#__PURE__*/jsxRuntime.jsx("span", _objectSpread(_objectSpread({
|
|
115
|
+
className: classNames(className, !!children && "underline decoration-dotted cursor-pointer")
|
|
116
|
+
}, props), {}, {
|
|
117
|
+
children: label
|
|
118
|
+
}))
|
|
119
|
+
});
|
|
120
|
+
return children ? /*#__PURE__*/jsxRuntime.jsxs(core.Dropdown, {
|
|
121
|
+
showArrow: true,
|
|
122
|
+
closeOnClick: true,
|
|
123
|
+
children: [dtLabel, children]
|
|
124
|
+
}) : dtLabel;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
exports.DateDuration = DateDuration;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function intPart(floatNum) {
|
|
4
|
+
if (floatNum < -0.0000001) {
|
|
5
|
+
return Math.ceil(floatNum - 0.0000001);
|
|
6
|
+
}
|
|
7
|
+
return Math.floor(floatNum + 0.0000001);
|
|
8
|
+
}
|
|
9
|
+
var delta = 1;
|
|
10
|
+
function GregToIsl(arg) {
|
|
11
|
+
var d = parseInt(arg.CDay.value);
|
|
12
|
+
var m = parseInt(arg.CMonth.value);
|
|
13
|
+
var y = parseInt(arg.CYear.value);
|
|
14
|
+
var jd,
|
|
15
|
+
l,
|
|
16
|
+
jd1,
|
|
17
|
+
n,
|
|
18
|
+
j,
|
|
19
|
+
delta = 1;
|
|
20
|
+
if (y > 1582 || y == 1582 && m > 10 || y == 1582 && m == 10 && d > 14) {
|
|
21
|
+
//added delta=1 on jd to comply isna rulling 2007
|
|
22
|
+
jd = intPart(1461 * (y + 4800 + intPart((m - 14) / 12)) / 4) + intPart(367 * (m - 2 - 12 * intPart((m - 14) / 12)) / 12) - intPart(3 * intPart((y + 4900 + intPart((m - 14) / 12)) / 100) / 4) + d - 32075 + delta;
|
|
23
|
+
} else {
|
|
24
|
+
//added +1 on jd to comply isna rulling
|
|
25
|
+
jd = 367 * y - intPart(7 * (y + 5001 + intPart((m - 9) / 7)) / 4) + intPart(275 * m / 9) + d + 1729777 + delta;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//added -1 on jd1 to comply isna rulling
|
|
29
|
+
jd1 = jd - delta;
|
|
30
|
+
l = jd - 1948440 + 10632;
|
|
31
|
+
n = intPart((l - 1) / 10631);
|
|
32
|
+
l = l - 10631 * n + 354;
|
|
33
|
+
j = intPart((10985 - l) / 5316) * intPart(50 * l / 17719) + intPart(l / 5670) * intPart(43 * l / 15238);
|
|
34
|
+
l = l - intPart((30 - j) / 15) * intPart(17719 * j / 50) - intPart(j / 16) * intPart(15238 * j / 43) + 29;
|
|
35
|
+
m = intPart(24 * l / 709);
|
|
36
|
+
d = l - intPart(709 * m / 24);
|
|
37
|
+
y = 30 * n + j - 30;
|
|
38
|
+
return {
|
|
39
|
+
d: d,
|
|
40
|
+
m: m,
|
|
41
|
+
y: y,
|
|
42
|
+
dateOfWeek: jd1 % 7,
|
|
43
|
+
dayName: weekDay(jd1 % 7)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function IslToGreg(arg) {
|
|
47
|
+
var d = parseInt(arg.HDay.value);
|
|
48
|
+
var m = parseInt(arg.HMonth.value);
|
|
49
|
+
var y = parseInt(arg.HYear.value);
|
|
50
|
+
//added - delta=1 on jd to comply isna rulling
|
|
51
|
+
var jd = intPart((11 * y + 3) / 30) + 354 * y + 30 * m - intPart((m - 1) / 2) + d + 1948440 - 385 - delta;
|
|
52
|
+
var l, n, i, j, k;
|
|
53
|
+
if (jd > 2299160) {
|
|
54
|
+
l = jd + 68569;
|
|
55
|
+
n = intPart(4 * l / 146097);
|
|
56
|
+
l = l - intPart((146097 * n + 3) / 4);
|
|
57
|
+
i = intPart(4000 * (l + 1) / 1461001);
|
|
58
|
+
l = l - intPart(1461 * i / 4) + 31;
|
|
59
|
+
j = intPart(80 * l / 2447);
|
|
60
|
+
d = l - intPart(2447 * j / 80);
|
|
61
|
+
l = intPart(j / 11);
|
|
62
|
+
m = j + 2 - 12 * l;
|
|
63
|
+
y = 100 * (n - 49) + i + l;
|
|
64
|
+
} else {
|
|
65
|
+
j = jd + 1402;
|
|
66
|
+
k = intPart((j - 1) / 1461);
|
|
67
|
+
l = j - 1461 * k;
|
|
68
|
+
n = intPart((l - 1) / 365) - intPart(l / 1461);
|
|
69
|
+
i = l - 365 * n + 30;
|
|
70
|
+
j = intPart(80 * i / 2447);
|
|
71
|
+
d = i - intPart(2447 * j / 80);
|
|
72
|
+
i = intPart(j / 11);
|
|
73
|
+
m = j + 2 - 12 * i;
|
|
74
|
+
y = 4 * k + n + i - 4716;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//arg.CDay.value=d
|
|
78
|
+
//arg.CMonth.value=m
|
|
79
|
+
//arg.CYear.value=y
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
d: d,
|
|
83
|
+
m: m,
|
|
84
|
+
y: y,
|
|
85
|
+
dateOfWeek: jd % 7,
|
|
86
|
+
dayName: weekDay(jd % 7)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function weekDay(wdn) {
|
|
90
|
+
if (wdn == 0) {
|
|
91
|
+
return "Mon";
|
|
92
|
+
}
|
|
93
|
+
if (wdn == 1) {
|
|
94
|
+
return "Tue";
|
|
95
|
+
}
|
|
96
|
+
if (wdn == 2) {
|
|
97
|
+
return "Wed";
|
|
98
|
+
}
|
|
99
|
+
if (wdn == 3) {
|
|
100
|
+
return "Thu";
|
|
101
|
+
}
|
|
102
|
+
if (wdn == 4) {
|
|
103
|
+
return "Fri";
|
|
104
|
+
}
|
|
105
|
+
if (wdn == 5) {
|
|
106
|
+
return "Sat";
|
|
107
|
+
}
|
|
108
|
+
if (wdn == 6) {
|
|
109
|
+
return "Sun";
|
|
110
|
+
}
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
function GregToHijri(gregDate) {
|
|
114
|
+
var hijriDate = GregToIsl({
|
|
115
|
+
CDay: {
|
|
116
|
+
value: gregDate.getDate()
|
|
117
|
+
},
|
|
118
|
+
CYear: {
|
|
119
|
+
value: gregDate.getFullYear()
|
|
120
|
+
},
|
|
121
|
+
CMonth: {
|
|
122
|
+
value: gregDate.getMonth() + 1
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
year: hijriDate.y,
|
|
127
|
+
month: hijriDate.m,
|
|
128
|
+
date: hijriDate.d,
|
|
129
|
+
hours: gregDate.getHours(),
|
|
130
|
+
minutes: gregDate.getMinutes(),
|
|
131
|
+
seconds: gregDate.getSeconds(),
|
|
132
|
+
milliseconds: gregDate.getMilliseconds(),
|
|
133
|
+
day: hijriDate.dateOfWeek,
|
|
134
|
+
dayName: hijriDate.dayName
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function HijriToGreg(hijriDate) {
|
|
138
|
+
var gregDate = IslToGreg({
|
|
139
|
+
HDay: {
|
|
140
|
+
value: hijriDate._date || hijriDate.date
|
|
141
|
+
},
|
|
142
|
+
HYear: {
|
|
143
|
+
value: hijriDate._year || hijriDate.year
|
|
144
|
+
},
|
|
145
|
+
HMonth: {
|
|
146
|
+
value: hijriDate._month || hijriDate.month
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return new Date(gregDate.y, gregDate.m - 1, gregDate.d, hijriDate.getHours(), hijriDate.getMinutes(), hijriDate.getSeconds(), hijriDate.getMilliseconds());
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
exports.GregToHijri = GregToHijri;
|
|
153
|
+
exports.HijriToGreg = HijriToGreg;
|
|
154
|
+
exports.weekDay = weekDay;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var dateFormat = function () {
|
|
6
|
+
var token = /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,
|
|
7
|
+
pad = function pad(val, len) {
|
|
8
|
+
val = String(val);
|
|
9
|
+
len = len || 2;
|
|
10
|
+
while (val.length < len) val = "0" + val;
|
|
11
|
+
return val;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Regexes and supporting functions are cached through closure
|
|
15
|
+
return function (date, mask) {
|
|
16
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
17
|
+
utc: false
|
|
18
|
+
};
|
|
19
|
+
var _require$default = require("./HijriDate")["default"],
|
|
20
|
+
locales = _require$default.locales,
|
|
21
|
+
defaultLocale = _require$default.defaultLocale;
|
|
22
|
+
options.locale = options.locale || defaultLocale;
|
|
23
|
+
if (!locales[options.locale]) {
|
|
24
|
+
throw new Error("Locale ".concat(options.locale, " is not supported yet .\n Please, try to extend \"HijriDate.locales\" :\n i.e: HijriDate.locales.").concat(options.locale, " = {dayNames:[..14 items..], monthNames:[..24 items..]}\n "));
|
|
25
|
+
}
|
|
26
|
+
// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
|
|
27
|
+
if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
|
|
28
|
+
mask = date;
|
|
29
|
+
date = undefined;
|
|
30
|
+
}
|
|
31
|
+
mask = String(masks[mask] || mask || masks["default"]);
|
|
32
|
+
|
|
33
|
+
// Allow setting the utc argument via the mask
|
|
34
|
+
if (mask.slice(0, 4) == "UTC:") {
|
|
35
|
+
mask = mask.slice(4);
|
|
36
|
+
options.utc = true;
|
|
37
|
+
}
|
|
38
|
+
var _ = options.utc ? "getUTC" : "get",
|
|
39
|
+
d = date[_ + "Date"](),
|
|
40
|
+
D = date[_ + "Day"](),
|
|
41
|
+
M = date[_ + "Month"](),
|
|
42
|
+
mIndex = date[_ + "MonthIndex"](),
|
|
43
|
+
y = date[_ + "FullYear"](),
|
|
44
|
+
H = date[_ + "Hours"](),
|
|
45
|
+
m = date[_ + "Minutes"](),
|
|
46
|
+
s = date[_ + "Seconds"](),
|
|
47
|
+
L = date[_ + "Milliseconds"](),
|
|
48
|
+
o = options.utc ? 0 : date.getTimezoneOffset(),
|
|
49
|
+
flags = {
|
|
50
|
+
d: d,
|
|
51
|
+
dd: pad(d),
|
|
52
|
+
ddd: locales[options.locale].dayNames[D === 7 ? 0 : D + 1],
|
|
53
|
+
dddd: locales[options.locale].dayNames[(D === 7 ? 0 : D + 1) + 7],
|
|
54
|
+
ee: locales[options.locale].dayNames[D],
|
|
55
|
+
eee: locales[options.locale].dayNames[D + 7],
|
|
56
|
+
eeee: locales[options.locale].dayNames[D + 14],
|
|
57
|
+
eeeeee: locales[options.locale].dayNames[D],
|
|
58
|
+
M: M,
|
|
59
|
+
MM: pad(M),
|
|
60
|
+
MMM: locales[options.locale].monthNames[mIndex],
|
|
61
|
+
MMMM: locales[options.locale].monthNames[mIndex + 12],
|
|
62
|
+
yy: String(y).slice(2),
|
|
63
|
+
yyyy: y,
|
|
64
|
+
h: H % 12 || 12,
|
|
65
|
+
hh: pad(H % 12 || 12),
|
|
66
|
+
H: H,
|
|
67
|
+
HH: pad(H),
|
|
68
|
+
m: m,
|
|
69
|
+
mm: pad(m),
|
|
70
|
+
s: s,
|
|
71
|
+
ss: pad(s),
|
|
72
|
+
l: pad(L, 3),
|
|
73
|
+
L: pad(L > 99 ? Math.round(L / 10) : L),
|
|
74
|
+
a: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
75
|
+
aa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
76
|
+
aaa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
77
|
+
aaaa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
78
|
+
aaaaa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
79
|
+
"'at'": locales[options.locale].separator,
|
|
80
|
+
t: H < 12 ? "a" : "p",
|
|
81
|
+
tt: H < 12 ? "am" : "pm",
|
|
82
|
+
T: H < 12 ? "A" : "P",
|
|
83
|
+
TT: H < 12 ? "AM" : "PM",
|
|
84
|
+
// Z: options.utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
|
|
85
|
+
o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
|
|
86
|
+
S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
|
|
87
|
+
};
|
|
88
|
+
return mask.replace(token, function ($0) {
|
|
89
|
+
if ($0 === "P") return "".concat(flags.d, "/").concat(flags.M, "/").concat(flags.yyyy, " ");
|
|
90
|
+
if ($0.startsWith("PP")) return "".concat(flags.MMM, " ").concat(flags.dd, ", ").concat(flags.yyyy, " ");
|
|
91
|
+
if ($0 === "p") return "".concat(flags.h, ":").concat(flags.m, " ").concat(flags.a);
|
|
92
|
+
if ($0.startsWith("pp")) return "".concat(flags.hh, ":").concat(flags.mm, ":").concat(flags.ss, " ").concat(flags.a);
|
|
93
|
+
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
}();
|
|
97
|
+
|
|
98
|
+
// Some common format strings
|
|
99
|
+
var masks = {
|
|
100
|
+
"default": "ddd MMM dd yyyy HH:mm:ss",
|
|
101
|
+
shortDate: "M/d/yy",
|
|
102
|
+
mediumDate: "MMM d, yyyy",
|
|
103
|
+
longDate: "MMMM d, yyyy",
|
|
104
|
+
fullDate: "dddd, MMMM d, yyyy",
|
|
105
|
+
shortTime: "h:mm TT",
|
|
106
|
+
mediumTime: "h:mm:ss TT",
|
|
107
|
+
longTime: "h:mm:ss TT Z",
|
|
108
|
+
isoDate: "yyyy-MM-dd",
|
|
109
|
+
isoTime: "HH:mm:ss",
|
|
110
|
+
isoDateTime: "yyyy-MM-dd'T'HH:mm:ss",
|
|
111
|
+
isoUtcDateTime: "UTC:yyyy-MM-dd'T'HH:mm:ss'Z'"
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
exports.default = dateFormat;
|
|
115
|
+
exports.masks = masks;
|