@react-fabric/date 1.0.0-beta.32 → 1.0.0-beta.34
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/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 +1 -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 +1 -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 -40
- package/package.json +4 -6
- 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 +20 -3
- package/src/types/index.ts +8 -43
- package/src/utils/dateUtil.ts +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 -177
- 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 -176
- 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.module.css +0 -30
- package/src/superdate/Superdate.tsx +0 -198
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CssProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
2
2
|
export type DateLike = Date | string | number;
|
|
3
3
|
export type DateParsed = Date | undefined;
|
|
4
4
|
export declare enum PageType {
|
|
@@ -18,6 +18,13 @@ export declare enum DatePart {
|
|
|
18
18
|
YEAR = "$year",
|
|
19
19
|
DECADE = "$decade"
|
|
20
20
|
}
|
|
21
|
+
export interface EventType<D = DateLike> {
|
|
22
|
+
label: string;
|
|
23
|
+
icon?: string;
|
|
24
|
+
start: D;
|
|
25
|
+
end: D;
|
|
26
|
+
hijri?: boolean;
|
|
27
|
+
}
|
|
21
28
|
export interface BaseProps {
|
|
22
29
|
min?: DateLike;
|
|
23
30
|
max?: DateLike;
|
|
@@ -34,42 +41,3 @@ export interface RangeProps extends BaseProps, CssProp, TestProps {
|
|
|
34
41
|
onChange?: (dates: [start: string, end: string]) => void;
|
|
35
42
|
presets?: Record<string, [DateLike, DateLike]>;
|
|
36
43
|
}
|
|
37
|
-
export interface EventType<D = DateLike> {
|
|
38
|
-
label: string;
|
|
39
|
-
icon?: string;
|
|
40
|
-
start: D;
|
|
41
|
-
end: D;
|
|
42
|
-
hijri?: boolean;
|
|
43
|
-
}
|
|
44
|
-
export interface PresetType {
|
|
45
|
-
value: string;
|
|
46
|
-
label: string;
|
|
47
|
-
}
|
|
48
|
-
export interface SuperDateProps extends TestProps {
|
|
49
|
-
as?: "button" | "chip";
|
|
50
|
-
color?: ColorType;
|
|
51
|
-
variant?: "solid" | "outline" | "link";
|
|
52
|
-
disabled?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* relative date value
|
|
55
|
-
*/
|
|
56
|
-
value?: string;
|
|
57
|
-
/**
|
|
58
|
-
* change handler
|
|
59
|
-
*/
|
|
60
|
-
onChange?: (value: string, dates: [string, string]) => void;
|
|
61
|
-
/**
|
|
62
|
-
* list of calendar events
|
|
63
|
-
*/
|
|
64
|
-
events?: EventType[];
|
|
65
|
-
/**
|
|
66
|
-
* list of calendar events
|
|
67
|
-
*/
|
|
68
|
-
recurringEvents?: EventType[];
|
|
69
|
-
/**
|
|
70
|
-
* list of relative presets
|
|
71
|
-
*
|
|
72
|
-
* {value:'$year-5|$year', label:'last 5 years'}
|
|
73
|
-
*/
|
|
74
|
-
presets?: PresetType[];
|
|
75
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/date",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.34",
|
|
4
4
|
"description": "RUF: Date package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,10 +33,8 @@
|
|
|
33
33
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@react-fabric/
|
|
38
|
-
"@react-fabric/form": "^1.0.0-beta.32",
|
|
39
|
-
"@react-fabric/utilities": "^1.0.0-beta.32",
|
|
36
|
+
"@react-fabric/core": "^1.0.0-beta.34",
|
|
37
|
+
"@react-fabric/utilities": "^1.0.0-beta.34",
|
|
40
38
|
"classnames": "^2.5.1",
|
|
41
39
|
"date-fns": "^4.0.0",
|
|
42
40
|
"resize-observer-polyfill": "^1.5.1"
|
|
@@ -54,5 +52,5 @@
|
|
|
54
52
|
"node": ">=18.12.0",
|
|
55
53
|
"npm": ">=8.19.0"
|
|
56
54
|
},
|
|
57
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "dcd1c1b247b6597b168a0649d2b3a53463b9c37e"
|
|
58
56
|
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
function intPart(floatNum) {
|
|
2
|
+
if (floatNum < -0.0000001) {
|
|
3
|
+
return Math.ceil(floatNum - 0.0000001)
|
|
4
|
+
}
|
|
5
|
+
return Math.floor(floatNum + 0.0000001)
|
|
6
|
+
}
|
|
7
|
+
var delta = 1
|
|
8
|
+
|
|
9
|
+
function GregToIsl(arg) {
|
|
10
|
+
|
|
11
|
+
let d = parseInt(arg.CDay.value)
|
|
12
|
+
let m = parseInt(arg.CMonth.value)
|
|
13
|
+
let y = parseInt(arg.CYear.value)
|
|
14
|
+
let jd, l, jd1, n, j, delta = 1;
|
|
15
|
+
if ((y > 1582) || ((y == 1582) && (m > 10)) || ((y == 1582) && (m == 10) && (d > 14))) {
|
|
16
|
+
//added delta=1 on jd to comply isna rulling 2007
|
|
17
|
+
jd = intPart((1461 * (y + 4800 + intPart((m - 14) / 12))) / 4) + intPart((367 * (m - 2 - 12 * (intPart((m - 14) / 12)))) / 12) -
|
|
18
|
+
intPart((3 * (intPart((y + 4900 + intPart((m - 14) / 12)) / 100))) / 4) + d - 32075 + delta
|
|
19
|
+
} else {
|
|
20
|
+
//added +1 on jd to comply isna rulling
|
|
21
|
+
jd = 367 * y - intPart((7 * (y + 5001 + intPart((m - 9) / 7))) / 4) + intPart((275 * m) / 9) + d + 1729777 + delta
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//added -1 on jd1 to comply isna rulling
|
|
25
|
+
jd1 = jd - delta
|
|
26
|
+
l = jd - 1948440 + 10632
|
|
27
|
+
n = intPart((l - 1) / 10631)
|
|
28
|
+
l = l - 10631 * n + 354
|
|
29
|
+
j = (intPart((10985 - l) / 5316)) * (intPart((50 * l) / 17719)) + (intPart(l / 5670)) * (intPart((43 * l) / 15238))
|
|
30
|
+
l = l - (intPart((30 - j) / 15)) * (intPart((17719 * j) / 50)) - (intPart(j / 16)) * (intPart((15238 * j) / 43)) + 29
|
|
31
|
+
m = intPart((24 * l) / 709)
|
|
32
|
+
d = l - intPart((709 * m) / 24)
|
|
33
|
+
y = 30 * n + j - 30
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
d,
|
|
37
|
+
m,
|
|
38
|
+
y,
|
|
39
|
+
dateOfWeek: jd1 % 7,
|
|
40
|
+
dayName:weekDay(jd1 % 7),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function IslToGreg(arg) {
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
let d = parseInt(arg.HDay.value)
|
|
49
|
+
let m = parseInt(arg.HMonth.value)
|
|
50
|
+
let y = parseInt(arg.HYear.value)
|
|
51
|
+
//added - delta=1 on jd to comply isna rulling
|
|
52
|
+
let jd = intPart((11 * y + 3) / 30) + 354 * y + 30 * m - intPart((m - 1) / 2) + d + 1948440 - 385 - delta
|
|
53
|
+
|
|
54
|
+
let l,n ,i ,j,k ;
|
|
55
|
+
|
|
56
|
+
if (jd > 2299160) {
|
|
57
|
+
l = jd + 68569
|
|
58
|
+
n = intPart((4 * l) / 146097)
|
|
59
|
+
l = l - intPart((146097 * n + 3) / 4)
|
|
60
|
+
i = intPart((4000 * (l + 1)) / 1461001)
|
|
61
|
+
l = l - intPart((1461 * i) / 4) + 31
|
|
62
|
+
j = intPart((80 * l) / 2447)
|
|
63
|
+
d = l - intPart((2447 * j) / 80)
|
|
64
|
+
l = intPart(j / 11)
|
|
65
|
+
m = j + 2 - 12 * l
|
|
66
|
+
y = 100 * (n - 49) + i + l
|
|
67
|
+
} else {
|
|
68
|
+
j = jd + 1402
|
|
69
|
+
k = intPart((j - 1) / 1461)
|
|
70
|
+
l = j - 1461 * k
|
|
71
|
+
n = intPart((l - 1) / 365) - intPart(l / 1461)
|
|
72
|
+
i = l - 365 * n + 30
|
|
73
|
+
j = intPart((80 * i) / 2447)
|
|
74
|
+
d = i - intPart((2447 * j) / 80)
|
|
75
|
+
i = intPart(j / 11)
|
|
76
|
+
m = j + 2 - 12 * i
|
|
77
|
+
y = 4 * k + n + i - 4716
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//arg.CDay.value=d
|
|
81
|
+
//arg.CMonth.value=m
|
|
82
|
+
//arg.CYear.value=y
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
d,
|
|
86
|
+
m,
|
|
87
|
+
y,
|
|
88
|
+
dateOfWeek: jd % 7,
|
|
89
|
+
dayName: weekDay(jd % 7),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
export function weekDay(wdn) {
|
|
97
|
+
if (wdn == 0) {
|
|
98
|
+
return "Mon"
|
|
99
|
+
}
|
|
100
|
+
if (wdn == 1) {
|
|
101
|
+
return "Tue"
|
|
102
|
+
}
|
|
103
|
+
if (wdn == 2) {
|
|
104
|
+
return "Wed"
|
|
105
|
+
}
|
|
106
|
+
if (wdn == 3) {
|
|
107
|
+
return "Thu"
|
|
108
|
+
}
|
|
109
|
+
if (wdn == 4) {
|
|
110
|
+
return "Fri"
|
|
111
|
+
}
|
|
112
|
+
if (wdn == 5) {
|
|
113
|
+
return "Sat"
|
|
114
|
+
}
|
|
115
|
+
if (wdn == 6) {
|
|
116
|
+
return "Sun"
|
|
117
|
+
}
|
|
118
|
+
return ""
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function GregToHijri(gregDate) {
|
|
123
|
+
const hijriDate = GregToIsl({
|
|
124
|
+
CDay: {
|
|
125
|
+
value: gregDate.getDate()
|
|
126
|
+
},
|
|
127
|
+
CYear: {
|
|
128
|
+
value: gregDate.getFullYear()
|
|
129
|
+
},
|
|
130
|
+
CMonth: {
|
|
131
|
+
value: gregDate.getMonth() + 1
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
year: hijriDate.y,
|
|
137
|
+
month: hijriDate.m,
|
|
138
|
+
date: hijriDate.d,
|
|
139
|
+
hours: gregDate.getHours(),
|
|
140
|
+
minutes: gregDate.getMinutes(),
|
|
141
|
+
seconds: gregDate.getSeconds(),
|
|
142
|
+
milliseconds: gregDate.getMilliseconds(),
|
|
143
|
+
day: hijriDate.dateOfWeek,
|
|
144
|
+
dayName: hijriDate.dayName
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
function HijriToGreg(hijriDate) {
|
|
150
|
+
const gregDate = IslToGreg({
|
|
151
|
+
HDay: {
|
|
152
|
+
value: hijriDate._date || hijriDate.date
|
|
153
|
+
},
|
|
154
|
+
HYear: {
|
|
155
|
+
value: hijriDate._year || hijriDate.year
|
|
156
|
+
},
|
|
157
|
+
HMonth: {
|
|
158
|
+
value: hijriDate._month || hijriDate.month
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
return new Date(gregDate.y,
|
|
163
|
+
gregDate.m -1 ,
|
|
164
|
+
gregDate.d,
|
|
165
|
+
hijriDate.getHours(),
|
|
166
|
+
hijriDate.getMinutes() ,
|
|
167
|
+
hijriDate.getSeconds(),
|
|
168
|
+
hijriDate.getMilliseconds()
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export {GregToHijri};
|
|
174
|
+
|
|
175
|
+
export {HijriToGreg};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
const dateFormat = (function () {
|
|
2
|
+
const token =
|
|
3
|
+
/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,
|
|
4
|
+
timezone =
|
|
5
|
+
/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
|
|
6
|
+
timezoneClip = /[^-+\dA-Z]/g,
|
|
7
|
+
pad = function (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 (
|
|
16
|
+
date,
|
|
17
|
+
mask,
|
|
18
|
+
options = {
|
|
19
|
+
utc: false,
|
|
20
|
+
},
|
|
21
|
+
) {
|
|
22
|
+
const { locales, defaultLocale } = require("./HijriDate").default;
|
|
23
|
+
options.locale = options.locale || defaultLocale;
|
|
24
|
+
if (!locales[options.locale]) {
|
|
25
|
+
throw new Error(`Locale ${options.locale} is not supported yet .
|
|
26
|
+
Please, try to extend "HijriDate.locales" :
|
|
27
|
+
i.e: HijriDate.locales.${options.locale} = {dayNames:[..14 items..], monthNames:[..24 items..]}
|
|
28
|
+
`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
|
|
32
|
+
if (
|
|
33
|
+
arguments.length == 1 &&
|
|
34
|
+
Object.prototype.toString.call(date) == "[object String]" &&
|
|
35
|
+
!/\d/.test(date)
|
|
36
|
+
) {
|
|
37
|
+
mask = date;
|
|
38
|
+
date = undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
mask = String(masks[mask] || mask || masks["default"]);
|
|
42
|
+
|
|
43
|
+
// Allow setting the utc argument via the mask
|
|
44
|
+
if (mask.slice(0, 4) == "UTC:") {
|
|
45
|
+
mask = mask.slice(4);
|
|
46
|
+
options.utc = true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var _ = options.utc ? "getUTC" : "get",
|
|
50
|
+
d = date[_ + "Date"](),
|
|
51
|
+
D = date[_ + "Day"](),
|
|
52
|
+
M = date[_ + "Month"](),
|
|
53
|
+
mIndex = date[_ + "MonthIndex"](),
|
|
54
|
+
y = date[_ + "FullYear"](),
|
|
55
|
+
H = date[_ + "Hours"](),
|
|
56
|
+
m = date[_ + "Minutes"](),
|
|
57
|
+
s = date[_ + "Seconds"](),
|
|
58
|
+
L = date[_ + "Milliseconds"](),
|
|
59
|
+
o = options.utc ? 0 : date.getTimezoneOffset(),
|
|
60
|
+
flags = {
|
|
61
|
+
d: d,
|
|
62
|
+
dd: pad(d),
|
|
63
|
+
ddd: locales[options.locale].dayNames[D === 7 ? 0 : D + 1],
|
|
64
|
+
dddd: locales[options.locale].dayNames[(D === 7 ? 0 : D + 1) + 7],
|
|
65
|
+
ee: locales[options.locale].dayNames[D],
|
|
66
|
+
eee: locales[options.locale].dayNames[D + 7],
|
|
67
|
+
eeee: locales[options.locale].dayNames[D + 14],
|
|
68
|
+
eeeeee: locales[options.locale].dayNames[D],
|
|
69
|
+
M,
|
|
70
|
+
MM: pad(M),
|
|
71
|
+
MMM: locales[options.locale].monthNames[mIndex],
|
|
72
|
+
MMMM: locales[options.locale].monthNames[mIndex + 12],
|
|
73
|
+
yy: String(y).slice(2),
|
|
74
|
+
yyyy: y,
|
|
75
|
+
h: H % 12 || 12,
|
|
76
|
+
hh: pad(H % 12 || 12),
|
|
77
|
+
H: H,
|
|
78
|
+
HH: pad(H),
|
|
79
|
+
m,
|
|
80
|
+
mm: pad(m),
|
|
81
|
+
s: s,
|
|
82
|
+
ss: pad(s),
|
|
83
|
+
l: pad(L, 3),
|
|
84
|
+
L: pad(L > 99 ? Math.round(L / 10) : L),
|
|
85
|
+
a: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
86
|
+
aa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
87
|
+
aaa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
88
|
+
aaaa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
89
|
+
aaaaa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
90
|
+
"'at'": locales[options.locale].separator,
|
|
91
|
+
t: H < 12 ? "a" : "p",
|
|
92
|
+
tt: H < 12 ? "am" : "pm",
|
|
93
|
+
T: H < 12 ? "A" : "P",
|
|
94
|
+
TT: H < 12 ? "AM" : "PM",
|
|
95
|
+
// Z: options.utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
|
|
96
|
+
o:
|
|
97
|
+
(o > 0 ? "-" : "+") +
|
|
98
|
+
pad(Math.floor(Math.abs(o) / 60) * 100 + (Math.abs(o) % 60), 4),
|
|
99
|
+
S: ["th", "st", "nd", "rd"][
|
|
100
|
+
d % 10 > 3 ? 0 : (((d % 100) - (d % 10) != 10) * d) % 10
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return mask.replace(token, function ($0) {
|
|
105
|
+
if ($0 === "P") return `${flags.d}/${flags.M}/${flags.yyyy} `;
|
|
106
|
+
if ($0.startsWith("PP"))
|
|
107
|
+
return `${flags.MMM} ${flags.dd}, ${flags.yyyy} `;
|
|
108
|
+
if ($0 === "p") return `${flags.h}:${flags.m} ${flags.a}`;
|
|
109
|
+
if ($0.startsWith("pp"))
|
|
110
|
+
return `${flags.hh}:${flags.mm}:${flags.ss} ${flags.a}`;
|
|
111
|
+
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
})();
|
|
115
|
+
|
|
116
|
+
// Some common format strings
|
|
117
|
+
export const masks = {
|
|
118
|
+
default: "ddd MMM dd yyyy HH:mm:ss",
|
|
119
|
+
shortDate: "M/d/yy",
|
|
120
|
+
mediumDate: "MMM d, yyyy",
|
|
121
|
+
longDate: "MMMM d, yyyy",
|
|
122
|
+
fullDate: "dddd, MMMM d, yyyy",
|
|
123
|
+
shortTime: "h:mm TT",
|
|
124
|
+
mediumTime: "h:mm:ss TT",
|
|
125
|
+
longTime: "h:mm:ss TT Z",
|
|
126
|
+
isoDate: "yyyy-MM-dd",
|
|
127
|
+
isoTime: "HH:mm:ss",
|
|
128
|
+
isoDateTime: "yyyy-MM-dd'T'HH:mm:ss",
|
|
129
|
+
isoUtcDateTime: "UTC:yyyy-MM-dd'T'HH:mm:ss'Z'",
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default dateFormat;
|