@izonnet-web-solution/react-native-date-time-picker-kit 0.0.0-stage → 1.0.1
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/DateTimePickerKit.podspec +22 -0
- package/LICENSE +20 -0
- package/README.md +652 -2
- package/android/build.gradle +36 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/datetimepickerkit/DatePickerHelper.kt +185 -0
- package/android/src/main/java/com/datetimepickerkit/DateTimePickerHelper.kt +214 -0
- package/android/src/main/java/com/datetimepickerkit/DateTimePickerKitModule.kt +258 -0
- package/android/src/main/java/com/datetimepickerkit/DateTimePickerKitPackage.kt +30 -0
- package/android/src/main/java/com/datetimepickerkit/TimePickerHelper.kt +208 -0
- package/ios/DateTimePickerKit.h +11 -0
- package/ios/DateTimePickerKit.mm +84 -0
- package/ios/DateTimePickerModule.swift +474 -0
- package/lib/module/NativeDateTimePickerKit.js +5 -0
- package/lib/module/NativeDateTimePickerKit.js.map +1 -0
- package/lib/module/components/CalendarPicker.js +419 -0
- package/lib/module/components/CalendarPicker.js.map +1 -0
- package/lib/module/components/ClockPicker.js +273 -0
- package/lib/module/components/ClockPicker.js.map +1 -0
- package/lib/module/components/DatePicker.js +181 -0
- package/lib/module/components/DatePicker.js.map +1 -0
- package/lib/module/components/DateRangePicker.js +158 -0
- package/lib/module/components/DateRangePicker.js.map +1 -0
- package/lib/module/components/DateTimePicker.js +674 -0
- package/lib/module/components/DateTimePicker.js.map +1 -0
- package/lib/module/components/MonthPicker.js +145 -0
- package/lib/module/components/MonthPicker.js.map +1 -0
- package/lib/module/components/TimePicker.js +142 -0
- package/lib/module/components/TimePicker.js.map +1 -0
- package/lib/module/components/TimeSlotPicker.js +118 -0
- package/lib/module/components/TimeSlotPicker.js.map +1 -0
- package/lib/module/components/WheelPicker.js +159 -0
- package/lib/module/components/WheelPicker.js.map +1 -0
- package/lib/module/components/YearPicker.js +151 -0
- package/lib/module/components/YearPicker.js.map +1 -0
- package/lib/module/components/common/ModalWrapper.js +136 -0
- package/lib/module/components/common/ModalWrapper.js.map +1 -0
- package/lib/module/components/common/PickerHeader.js +82 -0
- package/lib/module/components/common/PickerHeader.js.map +1 -0
- package/lib/module/components/common/PresetsBar.js +66 -0
- package/lib/module/components/common/PresetsBar.js.map +1 -0
- package/lib/module/errors/DateTimePickerError.js +12 -0
- package/lib/module/errors/DateTimePickerError.js.map +1 -0
- package/lib/module/hooks/useDateTimePicker.js +73 -0
- package/lib/module/hooks/useDateTimePicker.js.map +1 -0
- package/lib/module/index.js +40 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/localization/index.js +6 -0
- package/lib/module/localization/index.js.map +1 -0
- package/lib/module/localization/locales.js +186 -0
- package/lib/module/localization/locales.js.map +1 -0
- package/lib/module/localization/types.js +2 -0
- package/lib/module/localization/types.js.map +1 -0
- package/lib/module/localization/useLocale.js +176 -0
- package/lib/module/localization/useLocale.js.map +1 -0
- package/lib/module/native/NativeDateTimePicker.js +110 -0
- package/lib/module/native/NativeDateTimePicker.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/presets/datePresets.js +75 -0
- package/lib/module/presets/datePresets.js.map +1 -0
- package/lib/module/presets/index.js +4 -0
- package/lib/module/presets/index.js.map +1 -0
- package/lib/module/slots/index.js +4 -0
- package/lib/module/slots/index.js.map +1 -0
- package/lib/module/slots/timeSlots.js +59 -0
- package/lib/module/slots/timeSlots.js.map +1 -0
- package/lib/module/theme/defaultTheme.js +91 -0
- package/lib/module/theme/defaultTheme.js.map +1 -0
- package/lib/module/theme/index.js +6 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/types.js +2 -0
- package/lib/module/theme/types.js.map +1 -0
- package/lib/module/theme/useTheme.js +81 -0
- package/lib/module/theme/useTheme.js.map +1 -0
- package/lib/module/types/events.js +4 -0
- package/lib/module/types/events.js.map +1 -0
- package/lib/module/types/index.js +7 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/native.js +2 -0
- package/lib/module/types/native.js.map +1 -0
- package/lib/module/types/presentation.js +2 -0
- package/lib/module/types/presentation.js.map +1 -0
- package/lib/module/types/props.js +4 -0
- package/lib/module/types/props.js.map +1 -0
- package/lib/module/utils/constants.js +14 -0
- package/lib/module/utils/constants.js.map +1 -0
- package/lib/module/utils/dateConversion.js +224 -0
- package/lib/module/utils/dateConversion.js.map +1 -0
- package/lib/module/utils/dateFormatting.js +102 -0
- package/lib/module/utils/dateFormatting.js.map +1 -0
- package/lib/module/utils/dateValidation.js +161 -0
- package/lib/module/utils/dateValidation.js.map +1 -0
- package/lib/module/utils/index.js +7 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeDateTimePickerKit.d.ts +17 -0
- package/lib/typescript/src/NativeDateTimePickerKit.d.ts.map +1 -0
- package/lib/typescript/src/components/CalendarPicker.d.ts +51 -0
- package/lib/typescript/src/components/CalendarPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/ClockPicker.d.ts +22 -0
- package/lib/typescript/src/components/ClockPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/DatePicker.d.ts +44 -0
- package/lib/typescript/src/components/DatePicker.d.ts.map +1 -0
- package/lib/typescript/src/components/DateRangePicker.d.ts +56 -0
- package/lib/typescript/src/components/DateRangePicker.d.ts.map +1 -0
- package/lib/typescript/src/components/DateTimePicker.d.ts +7 -0
- package/lib/typescript/src/components/DateTimePicker.d.ts.map +1 -0
- package/lib/typescript/src/components/MonthPicker.d.ts +21 -0
- package/lib/typescript/src/components/MonthPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/TimePicker.d.ts +31 -0
- package/lib/typescript/src/components/TimePicker.d.ts.map +1 -0
- package/lib/typescript/src/components/TimeSlotPicker.d.ts +18 -0
- package/lib/typescript/src/components/TimeSlotPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/WheelPicker.d.ts +17 -0
- package/lib/typescript/src/components/WheelPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/YearPicker.d.ts +14 -0
- package/lib/typescript/src/components/YearPicker.d.ts.map +1 -0
- package/lib/typescript/src/components/common/ModalWrapper.d.ts +11 -0
- package/lib/typescript/src/components/common/ModalWrapper.d.ts.map +1 -0
- package/lib/typescript/src/components/common/PickerHeader.d.ts +13 -0
- package/lib/typescript/src/components/common/PickerHeader.d.ts.map +1 -0
- package/lib/typescript/src/components/common/PresetsBar.d.ts +12 -0
- package/lib/typescript/src/components/common/PresetsBar.d.ts.map +1 -0
- package/lib/typescript/src/errors/DateTimePickerError.d.ts +7 -0
- package/lib/typescript/src/errors/DateTimePickerError.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useDateTimePicker.d.ts +17 -0
- package/lib/typescript/src/hooks/useDateTimePicker.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +23 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/localization/index.d.ts +4 -0
- package/lib/typescript/src/localization/index.d.ts.map +1 -0
- package/lib/typescript/src/localization/locales.d.ts +12 -0
- package/lib/typescript/src/localization/locales.d.ts.map +1 -0
- package/lib/typescript/src/localization/types.d.ts +23 -0
- package/lib/typescript/src/localization/types.d.ts.map +1 -0
- package/lib/typescript/src/localization/useLocale.d.ts +31 -0
- package/lib/typescript/src/localization/useLocale.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeDateTimePicker.d.ts +14 -0
- package/lib/typescript/src/native/NativeDateTimePicker.d.ts.map +1 -0
- package/lib/typescript/src/presets/datePresets.d.ts +8 -0
- package/lib/typescript/src/presets/datePresets.d.ts.map +1 -0
- package/lib/typescript/src/presets/index.d.ts +2 -0
- package/lib/typescript/src/presets/index.d.ts.map +1 -0
- package/lib/typescript/src/slots/index.d.ts +2 -0
- package/lib/typescript/src/slots/index.d.ts.map +1 -0
- package/lib/typescript/src/slots/timeSlots.d.ts +18 -0
- package/lib/typescript/src/slots/timeSlots.d.ts.map +1 -0
- package/lib/typescript/src/theme/defaultTheme.d.ts +9 -0
- package/lib/typescript/src/theme/defaultTheme.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +4 -0
- package/lib/typescript/src/theme/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/types.d.ts +76 -0
- package/lib/typescript/src/theme/types.d.ts.map +1 -0
- package/lib/typescript/src/theme/useTheme.d.ts +4 -0
- package/lib/typescript/src/theme/useTheme.d.ts.map +1 -0
- package/lib/typescript/src/types/events.d.ts +8 -0
- package/lib/typescript/src/types/events.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +5 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/native.d.ts +26 -0
- package/lib/typescript/src/types/native.d.ts.map +1 -0
- package/lib/typescript/src/types/presentation.d.ts +26 -0
- package/lib/typescript/src/types/presentation.d.ts.map +1 -0
- package/lib/typescript/src/types/props.d.ts +221 -0
- package/lib/typescript/src/types/props.d.ts.map +1 -0
- package/lib/typescript/src/utils/constants.d.ts +12 -0
- package/lib/typescript/src/utils/constants.d.ts.map +1 -0
- package/lib/typescript/src/utils/dateConversion.d.ts +46 -0
- package/lib/typescript/src/utils/dateConversion.d.ts.map +1 -0
- package/lib/typescript/src/utils/dateFormatting.d.ts +8 -0
- package/lib/typescript/src/utils/dateFormatting.d.ts.map +1 -0
- package/lib/typescript/src/utils/dateValidation.d.ts +46 -0
- package/lib/typescript/src/utils/dateValidation.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +5 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/package.json +191 -4
- package/src/NativeDateTimePickerKit.ts +19 -0
- package/src/components/CalendarPicker.tsx +623 -0
- package/src/components/ClockPicker.tsx +403 -0
- package/src/components/DatePicker.tsx +276 -0
- package/src/components/DateRangePicker.tsx +251 -0
- package/src/components/DateTimePicker.tsx +1028 -0
- package/src/components/MonthPicker.tsx +216 -0
- package/src/components/TimePicker.tsx +203 -0
- package/src/components/TimeSlotPicker.tsx +163 -0
- package/src/components/WheelPicker.tsx +229 -0
- package/src/components/YearPicker.tsx +228 -0
- package/src/components/common/ModalWrapper.tsx +192 -0
- package/src/components/common/PickerHeader.tsx +121 -0
- package/src/components/common/PresetsBar.tsx +104 -0
- package/src/errors/DateTimePickerError.ts +29 -0
- package/src/hooks/useDateTimePicker.ts +100 -0
- package/src/index.tsx +92 -0
- package/src/localization/index.ts +3 -0
- package/src/localization/locales.ts +499 -0
- package/src/localization/types.ts +21 -0
- package/src/localization/useLocale.ts +197 -0
- package/src/native/NativeDateTimePicker.ts +154 -0
- package/src/presets/datePresets.ts +97 -0
- package/src/presets/index.ts +1 -0
- package/src/slots/index.ts +1 -0
- package/src/slots/timeSlots.ts +89 -0
- package/src/theme/defaultTheme.ts +102 -0
- package/src/theme/index.ts +3 -0
- package/src/theme/types.ts +82 -0
- package/src/theme/useTheme.ts +98 -0
- package/src/types/events.ts +8 -0
- package/src/types/index.ts +4 -0
- package/src/types/native.ts +28 -0
- package/src/types/presentation.ts +28 -0
- package/src/types/props.ts +291 -0
- package/src/utils/constants.ts +15 -0
- package/src/utils/dateConversion.ts +273 -0
- package/src/utils/dateFormatting.ts +166 -0
- package/src/utils/dateValidation.ts +178 -0
- package/src/utils/index.ts +4 -0
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import type { LocaleData } from './types';
|
|
2
|
+
|
|
3
|
+
export const enLocale: LocaleData = {
|
|
4
|
+
code: 'en',
|
|
5
|
+
isRTL: false,
|
|
6
|
+
firstDayOfWeek: 0,
|
|
7
|
+
months: [
|
|
8
|
+
'January',
|
|
9
|
+
'February',
|
|
10
|
+
'March',
|
|
11
|
+
'April',
|
|
12
|
+
'May',
|
|
13
|
+
'June',
|
|
14
|
+
'July',
|
|
15
|
+
'August',
|
|
16
|
+
'September',
|
|
17
|
+
'October',
|
|
18
|
+
'November',
|
|
19
|
+
'December',
|
|
20
|
+
],
|
|
21
|
+
monthsShort: [
|
|
22
|
+
'Jan',
|
|
23
|
+
'Feb',
|
|
24
|
+
'Mar',
|
|
25
|
+
'Apr',
|
|
26
|
+
'May',
|
|
27
|
+
'Jun',
|
|
28
|
+
'Jul',
|
|
29
|
+
'Aug',
|
|
30
|
+
'Sep',
|
|
31
|
+
'Oct',
|
|
32
|
+
'Nov',
|
|
33
|
+
'Dec',
|
|
34
|
+
],
|
|
35
|
+
weekdays: [
|
|
36
|
+
'Sunday',
|
|
37
|
+
'Monday',
|
|
38
|
+
'Tuesday',
|
|
39
|
+
'Wednesday',
|
|
40
|
+
'Thursday',
|
|
41
|
+
'Friday',
|
|
42
|
+
'Saturday',
|
|
43
|
+
],
|
|
44
|
+
weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
45
|
+
weekdaysMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
|
46
|
+
am: 'AM',
|
|
47
|
+
pm: 'PM',
|
|
48
|
+
confirmText: 'Confirm',
|
|
49
|
+
cancelText: 'Cancel',
|
|
50
|
+
todayText: 'Today',
|
|
51
|
+
selectDateTitle: 'Select Date',
|
|
52
|
+
selectTimeTitle: 'Select Time',
|
|
53
|
+
selectDateTimeTitle: 'Select Date & Time',
|
|
54
|
+
selectRangeTitle: 'Select Date Range',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const hiLocale: LocaleData = {
|
|
58
|
+
code: 'hi',
|
|
59
|
+
isRTL: false,
|
|
60
|
+
firstDayOfWeek: 0,
|
|
61
|
+
months: [
|
|
62
|
+
'जनवरी',
|
|
63
|
+
'फ़रवरी',
|
|
64
|
+
'मार्च',
|
|
65
|
+
'अप्रैल',
|
|
66
|
+
'मई',
|
|
67
|
+
'जून',
|
|
68
|
+
'जुलाई',
|
|
69
|
+
'अगस्त',
|
|
70
|
+
'सितंबर',
|
|
71
|
+
'अक्टूबर',
|
|
72
|
+
'नवंबर',
|
|
73
|
+
'दिसंबर',
|
|
74
|
+
],
|
|
75
|
+
monthsShort: [
|
|
76
|
+
'जन',
|
|
77
|
+
'फ़र',
|
|
78
|
+
'मार्च',
|
|
79
|
+
'अप्रै',
|
|
80
|
+
'मई',
|
|
81
|
+
'जून',
|
|
82
|
+
'जुला',
|
|
83
|
+
'अग',
|
|
84
|
+
'सित',
|
|
85
|
+
'अक्टू',
|
|
86
|
+
'नव',
|
|
87
|
+
'दिस',
|
|
88
|
+
],
|
|
89
|
+
weekdays: [
|
|
90
|
+
'रविवार',
|
|
91
|
+
'सोमवार',
|
|
92
|
+
'मंगलवार',
|
|
93
|
+
'बुधवार',
|
|
94
|
+
'गुरुवार',
|
|
95
|
+
'शुक्रवार',
|
|
96
|
+
'शनिवार',
|
|
97
|
+
],
|
|
98
|
+
weekdaysShort: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरु', 'शुक्र', 'शनि'],
|
|
99
|
+
weekdaysMin: ['र', 'सो', 'मं', 'बु', 'गु', 'शु', 'श'],
|
|
100
|
+
am: 'पूर्वाह्न',
|
|
101
|
+
pm: 'अपराह्न',
|
|
102
|
+
confirmText: 'पुष्टि करें',
|
|
103
|
+
cancelText: 'रद्द करें',
|
|
104
|
+
todayText: 'आज',
|
|
105
|
+
selectDateTitle: 'तारीख चुनें',
|
|
106
|
+
selectTimeTitle: 'समय चुनें',
|
|
107
|
+
selectDateTimeTitle: 'तारीख और समय चुनें',
|
|
108
|
+
selectRangeTitle: 'तारीख सीमा चुनें',
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const guLocale: LocaleData = {
|
|
112
|
+
code: 'gu',
|
|
113
|
+
isRTL: false,
|
|
114
|
+
firstDayOfWeek: 0,
|
|
115
|
+
months: [
|
|
116
|
+
'જાન્યુઆરી',
|
|
117
|
+
'ફેબ્રુઆરી',
|
|
118
|
+
'માર્ચ',
|
|
119
|
+
'એપ્રિલ',
|
|
120
|
+
'મે',
|
|
121
|
+
'જૂન',
|
|
122
|
+
'જુલાઈ',
|
|
123
|
+
'ઑગસ્ટ',
|
|
124
|
+
'સપ્ટેમ્બર',
|
|
125
|
+
'ઑક્ટોબર',
|
|
126
|
+
'નવેમ્બર',
|
|
127
|
+
'ડિસેમ્બર',
|
|
128
|
+
],
|
|
129
|
+
monthsShort: [
|
|
130
|
+
'જાન્યુ',
|
|
131
|
+
'ફેબ્રુ',
|
|
132
|
+
'માર્ચ',
|
|
133
|
+
'એપ્રિ',
|
|
134
|
+
'મે',
|
|
135
|
+
'જૂન',
|
|
136
|
+
'જુલા',
|
|
137
|
+
'ઑગ',
|
|
138
|
+
'સપ્ટે',
|
|
139
|
+
'ઑક્ટો',
|
|
140
|
+
'નવે',
|
|
141
|
+
'ડિસે',
|
|
142
|
+
],
|
|
143
|
+
weekdays: [
|
|
144
|
+
'રવિવાર',
|
|
145
|
+
'સોમવાર',
|
|
146
|
+
'મંગળવાર',
|
|
147
|
+
'બુધવાર',
|
|
148
|
+
'ગુરુવાર',
|
|
149
|
+
'શુક્રવાર',
|
|
150
|
+
'શનિવાર',
|
|
151
|
+
],
|
|
152
|
+
weekdaysShort: ['રવિ', 'સોમ', 'મંગળ', 'બુધ', 'ગુરુ', 'શુક્ર', 'શનિ'],
|
|
153
|
+
weekdaysMin: ['ર', 'સો', 'મં', 'બુ', 'ગુ', 'શુ', 'શ'],
|
|
154
|
+
am: 'સવાર',
|
|
155
|
+
pm: 'સાંજ',
|
|
156
|
+
confirmText: 'ખાતરી કરો',
|
|
157
|
+
cancelText: 'રદ કરો',
|
|
158
|
+
todayText: 'આજે',
|
|
159
|
+
selectDateTitle: 'તારીખ પસંદ કરો',
|
|
160
|
+
selectTimeTitle: 'સમય પસંદ કરો',
|
|
161
|
+
selectDateTimeTitle: 'તારીખ અને સમય પસંદ કરો',
|
|
162
|
+
selectRangeTitle: 'તારીખ શ્રેણી પસંદ કરો',
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const esLocale: LocaleData = {
|
|
166
|
+
code: 'es',
|
|
167
|
+
isRTL: false,
|
|
168
|
+
firstDayOfWeek: 1,
|
|
169
|
+
months: [
|
|
170
|
+
'Enero',
|
|
171
|
+
'Febrero',
|
|
172
|
+
'Marzo',
|
|
173
|
+
'Abril',
|
|
174
|
+
'Mayo',
|
|
175
|
+
'Junio',
|
|
176
|
+
'Julio',
|
|
177
|
+
'Agosto',
|
|
178
|
+
'Septiembre',
|
|
179
|
+
'Octubre',
|
|
180
|
+
'Noviembre',
|
|
181
|
+
'Diciembre',
|
|
182
|
+
],
|
|
183
|
+
monthsShort: [
|
|
184
|
+
'Ene',
|
|
185
|
+
'Feb',
|
|
186
|
+
'Mar',
|
|
187
|
+
'Abr',
|
|
188
|
+
'May',
|
|
189
|
+
'Jun',
|
|
190
|
+
'Jul',
|
|
191
|
+
'Ago',
|
|
192
|
+
'Sep',
|
|
193
|
+
'Oct',
|
|
194
|
+
'Nov',
|
|
195
|
+
'Dic',
|
|
196
|
+
],
|
|
197
|
+
weekdays: [
|
|
198
|
+
'Domingo',
|
|
199
|
+
'Lunes',
|
|
200
|
+
'Martes',
|
|
201
|
+
'Miércoles',
|
|
202
|
+
'Jueves',
|
|
203
|
+
'Viernes',
|
|
204
|
+
'Sábado',
|
|
205
|
+
],
|
|
206
|
+
weekdaysShort: ['Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'],
|
|
207
|
+
weekdaysMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sá'],
|
|
208
|
+
am: 'AM',
|
|
209
|
+
pm: 'PM',
|
|
210
|
+
confirmText: 'Confirmar',
|
|
211
|
+
cancelText: 'Cancelar',
|
|
212
|
+
todayText: 'Hoy',
|
|
213
|
+
selectDateTitle: 'Seleccionar Fecha',
|
|
214
|
+
selectTimeTitle: 'Seleccionar Hora',
|
|
215
|
+
selectDateTimeTitle: 'Seleccionar Fecha y Hora',
|
|
216
|
+
selectRangeTitle: 'Seleccionar Rango de Fechas',
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export const frLocale: LocaleData = {
|
|
220
|
+
code: 'fr',
|
|
221
|
+
isRTL: false,
|
|
222
|
+
firstDayOfWeek: 1,
|
|
223
|
+
months: [
|
|
224
|
+
'Janvier',
|
|
225
|
+
'Février',
|
|
226
|
+
'Mars',
|
|
227
|
+
'Avril',
|
|
228
|
+
'Mai',
|
|
229
|
+
'Juin',
|
|
230
|
+
'Juillet',
|
|
231
|
+
'Août',
|
|
232
|
+
'Septembre',
|
|
233
|
+
'Octobre',
|
|
234
|
+
'Novembre',
|
|
235
|
+
'Décembre',
|
|
236
|
+
],
|
|
237
|
+
monthsShort: [
|
|
238
|
+
'Janv',
|
|
239
|
+
'Févr',
|
|
240
|
+
'Mars',
|
|
241
|
+
'Avr',
|
|
242
|
+
'Mai',
|
|
243
|
+
'Juin',
|
|
244
|
+
'Juil',
|
|
245
|
+
'Août',
|
|
246
|
+
'Sept',
|
|
247
|
+
'Oct',
|
|
248
|
+
'Nov',
|
|
249
|
+
'Déc',
|
|
250
|
+
],
|
|
251
|
+
weekdays: [
|
|
252
|
+
'Dimanche',
|
|
253
|
+
'Lundi',
|
|
254
|
+
'Mardi',
|
|
255
|
+
'Mercredi',
|
|
256
|
+
'Jeudi',
|
|
257
|
+
'Vendredi',
|
|
258
|
+
'Samedi',
|
|
259
|
+
],
|
|
260
|
+
weekdaysShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
|
|
261
|
+
weekdaysMin: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
|
|
262
|
+
am: 'AM',
|
|
263
|
+
pm: 'PM',
|
|
264
|
+
confirmText: 'Confirmer',
|
|
265
|
+
cancelText: 'Annuler',
|
|
266
|
+
todayText: "Aujourd'hui",
|
|
267
|
+
selectDateTitle: 'Sélectionner la Date',
|
|
268
|
+
selectTimeTitle: "Sélectionner l'Heure",
|
|
269
|
+
selectDateTimeTitle: 'Sélectionner Date et Heure',
|
|
270
|
+
selectRangeTitle: 'Sélectionner la Plage de Dates',
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export const deLocale: LocaleData = {
|
|
274
|
+
code: 'de',
|
|
275
|
+
isRTL: false,
|
|
276
|
+
firstDayOfWeek: 1,
|
|
277
|
+
months: [
|
|
278
|
+
'Januar',
|
|
279
|
+
'Februar',
|
|
280
|
+
'März',
|
|
281
|
+
'April',
|
|
282
|
+
'Mai',
|
|
283
|
+
'Juni',
|
|
284
|
+
'Juli',
|
|
285
|
+
'August',
|
|
286
|
+
'September',
|
|
287
|
+
'Oktober',
|
|
288
|
+
'November',
|
|
289
|
+
'Dezember',
|
|
290
|
+
],
|
|
291
|
+
monthsShort: [
|
|
292
|
+
'Jan',
|
|
293
|
+
'Feb',
|
|
294
|
+
'Mär',
|
|
295
|
+
'Apr',
|
|
296
|
+
'Mai',
|
|
297
|
+
'Jun',
|
|
298
|
+
'Jul',
|
|
299
|
+
'Aug',
|
|
300
|
+
'Sep',
|
|
301
|
+
'Okt',
|
|
302
|
+
'Nov',
|
|
303
|
+
'Dez',
|
|
304
|
+
],
|
|
305
|
+
weekdays: [
|
|
306
|
+
'Sonntag',
|
|
307
|
+
'Montag',
|
|
308
|
+
'Dienstag',
|
|
309
|
+
'Mittwoch',
|
|
310
|
+
'Donnerstag',
|
|
311
|
+
'Freitag',
|
|
312
|
+
'Samstag',
|
|
313
|
+
],
|
|
314
|
+
weekdaysShort: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
|
|
315
|
+
weekdaysMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
|
|
316
|
+
am: 'Vorm.',
|
|
317
|
+
pm: 'Nachm.',
|
|
318
|
+
confirmText: 'Bestätigen',
|
|
319
|
+
cancelText: 'Abbrechen',
|
|
320
|
+
todayText: 'Heute',
|
|
321
|
+
selectDateTitle: 'Datum auswählen',
|
|
322
|
+
selectTimeTitle: 'Uhrzeit auswählen',
|
|
323
|
+
selectDateTimeTitle: 'Datum & Uhrzeit auswählen',
|
|
324
|
+
selectRangeTitle: 'Datumsbereich auswählen',
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
export const arLocale: LocaleData = {
|
|
328
|
+
code: 'ar',
|
|
329
|
+
isRTL: true,
|
|
330
|
+
firstDayOfWeek: 6, // Saturday
|
|
331
|
+
months: [
|
|
332
|
+
'يناير',
|
|
333
|
+
'فبراير',
|
|
334
|
+
'مارس',
|
|
335
|
+
'أبريل',
|
|
336
|
+
'مايو',
|
|
337
|
+
'يونيو',
|
|
338
|
+
'يوليو',
|
|
339
|
+
'أغسطس',
|
|
340
|
+
'سبتمبر',
|
|
341
|
+
'أكتوبر',
|
|
342
|
+
'نوفمبر',
|
|
343
|
+
'ديسمبر',
|
|
344
|
+
],
|
|
345
|
+
monthsShort: [
|
|
346
|
+
'ينا',
|
|
347
|
+
'فبر',
|
|
348
|
+
'مار',
|
|
349
|
+
'أبر',
|
|
350
|
+
'ماي',
|
|
351
|
+
'يون',
|
|
352
|
+
'يول',
|
|
353
|
+
'أغس',
|
|
354
|
+
'سبت',
|
|
355
|
+
'أكت',
|
|
356
|
+
'نوف',
|
|
357
|
+
'ديس',
|
|
358
|
+
],
|
|
359
|
+
weekdays: [
|
|
360
|
+
'الأحد',
|
|
361
|
+
'الاثنين',
|
|
362
|
+
'الثلاثاء',
|
|
363
|
+
'الأربعاء',
|
|
364
|
+
'الخميس',
|
|
365
|
+
'الجمعة',
|
|
366
|
+
'السبت',
|
|
367
|
+
],
|
|
368
|
+
weekdaysShort: ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
|
|
369
|
+
weekdaysMin: ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
|
|
370
|
+
am: 'ص',
|
|
371
|
+
pm: 'م',
|
|
372
|
+
confirmText: 'تأكيد',
|
|
373
|
+
cancelText: 'إلغاء',
|
|
374
|
+
todayText: 'اليوم',
|
|
375
|
+
selectDateTitle: 'اختر التاريخ',
|
|
376
|
+
selectTimeTitle: 'اختر الوقت',
|
|
377
|
+
selectDateTimeTitle: 'اختر التاريخ والوقت',
|
|
378
|
+
selectRangeTitle: 'اختر نطاق التاريخ',
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export const zhLocale: LocaleData = {
|
|
382
|
+
code: 'zh',
|
|
383
|
+
isRTL: false,
|
|
384
|
+
firstDayOfWeek: 1,
|
|
385
|
+
months: [
|
|
386
|
+
'一月',
|
|
387
|
+
'二月',
|
|
388
|
+
'三月',
|
|
389
|
+
'四月',
|
|
390
|
+
'五月',
|
|
391
|
+
'六月',
|
|
392
|
+
'七月',
|
|
393
|
+
'八月',
|
|
394
|
+
'九月',
|
|
395
|
+
'十月',
|
|
396
|
+
'十一月',
|
|
397
|
+
'十二月',
|
|
398
|
+
],
|
|
399
|
+
monthsShort: [
|
|
400
|
+
'1月',
|
|
401
|
+
'2月',
|
|
402
|
+
'3月',
|
|
403
|
+
'4月',
|
|
404
|
+
'5月',
|
|
405
|
+
'6月',
|
|
406
|
+
'7月',
|
|
407
|
+
'8月',
|
|
408
|
+
'9月',
|
|
409
|
+
'10月',
|
|
410
|
+
'11月',
|
|
411
|
+
'12月',
|
|
412
|
+
],
|
|
413
|
+
weekdays: [
|
|
414
|
+
'星期日',
|
|
415
|
+
'星期一',
|
|
416
|
+
'星期二',
|
|
417
|
+
'星期三',
|
|
418
|
+
'星期四',
|
|
419
|
+
'星期五',
|
|
420
|
+
'星期六',
|
|
421
|
+
],
|
|
422
|
+
weekdaysShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
|
|
423
|
+
weekdaysMin: ['日', '一', '二', '三', '四', '五', '六'],
|
|
424
|
+
am: '上午',
|
|
425
|
+
pm: '下午',
|
|
426
|
+
confirmText: '确认',
|
|
427
|
+
cancelText: '取消',
|
|
428
|
+
todayText: '今天',
|
|
429
|
+
selectDateTitle: '选择日期',
|
|
430
|
+
selectTimeTitle: '选择时间',
|
|
431
|
+
selectDateTimeTitle: '选择日期和时间',
|
|
432
|
+
selectRangeTitle: '选择日期范围',
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
export const jaLocale: LocaleData = {
|
|
436
|
+
code: 'ja',
|
|
437
|
+
isRTL: false,
|
|
438
|
+
firstDayOfWeek: 0,
|
|
439
|
+
months: [
|
|
440
|
+
'1月',
|
|
441
|
+
'2月',
|
|
442
|
+
'3月',
|
|
443
|
+
'4月',
|
|
444
|
+
'5月',
|
|
445
|
+
'6月',
|
|
446
|
+
'7月',
|
|
447
|
+
'8月',
|
|
448
|
+
'9月',
|
|
449
|
+
'10月',
|
|
450
|
+
'11月',
|
|
451
|
+
'12月',
|
|
452
|
+
],
|
|
453
|
+
monthsShort: [
|
|
454
|
+
'1月',
|
|
455
|
+
'2月',
|
|
456
|
+
'3月',
|
|
457
|
+
'4月',
|
|
458
|
+
'5月',
|
|
459
|
+
'6月',
|
|
460
|
+
'7月',
|
|
461
|
+
'8月',
|
|
462
|
+
'9月',
|
|
463
|
+
'10月',
|
|
464
|
+
'11月',
|
|
465
|
+
'12月',
|
|
466
|
+
],
|
|
467
|
+
weekdays: [
|
|
468
|
+
'日曜日',
|
|
469
|
+
'月曜日',
|
|
470
|
+
'火曜日',
|
|
471
|
+
'水曜日',
|
|
472
|
+
'木曜日',
|
|
473
|
+
'金曜日',
|
|
474
|
+
'土曜日',
|
|
475
|
+
],
|
|
476
|
+
weekdaysShort: ['日', '月', '火', '水', '木', '金', '土'],
|
|
477
|
+
weekdaysMin: ['日', '月', '火', '水', '木', '金', '土'],
|
|
478
|
+
am: '午前',
|
|
479
|
+
pm: '午後',
|
|
480
|
+
confirmText: '確定',
|
|
481
|
+
cancelText: 'キャンセル',
|
|
482
|
+
todayText: '今日',
|
|
483
|
+
selectDateTitle: '日付を選択',
|
|
484
|
+
selectTimeTitle: '時間を選択',
|
|
485
|
+
selectDateTimeTitle: '日時を選択',
|
|
486
|
+
selectRangeTitle: '期間を選択',
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
export const BUILTIN_LOCALES: Record<string, LocaleData> = {
|
|
490
|
+
en: enLocale,
|
|
491
|
+
hi: hiLocale,
|
|
492
|
+
gu: guLocale,
|
|
493
|
+
es: esLocale,
|
|
494
|
+
fr: frLocale,
|
|
495
|
+
de: deLocale,
|
|
496
|
+
ar: arLocale,
|
|
497
|
+
zh: zhLocale,
|
|
498
|
+
ja: jaLocale,
|
|
499
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface LocaleData {
|
|
2
|
+
code: string;
|
|
3
|
+
isRTL: boolean;
|
|
4
|
+
firstDayOfWeek: number; // 0 = Sunday, 1 = Monday
|
|
5
|
+
months: string[]; // 12 full month names
|
|
6
|
+
monthsShort: string[]; // 12 short month names
|
|
7
|
+
weekdays: string[]; // 7 full weekday names (Sun-Sat)
|
|
8
|
+
weekdaysShort: string[]; // 7 short weekday names (Sun-Sat)
|
|
9
|
+
weekdaysMin: string[]; // 7 min weekday names (e.g. S, M, T or Su, Mo)
|
|
10
|
+
am: string;
|
|
11
|
+
pm: string;
|
|
12
|
+
confirmText: string;
|
|
13
|
+
cancelText: string;
|
|
14
|
+
todayText: string;
|
|
15
|
+
selectDateTitle: string;
|
|
16
|
+
selectTimeTitle: string;
|
|
17
|
+
selectDateTimeTitle: string;
|
|
18
|
+
selectRangeTitle: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type PartialLocaleData = Partial<LocaleData> & { code?: string };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { BUILTIN_LOCALES, enLocale } from './locales';
|
|
3
|
+
import type { LocaleData, PartialLocaleData } from './types';
|
|
4
|
+
|
|
5
|
+
export function getDeviceLocale(): string {
|
|
6
|
+
try {
|
|
7
|
+
if (typeof Intl !== 'undefined' && Intl.DateTimeFormat) {
|
|
8
|
+
const resolved = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
9
|
+
if (resolved) {
|
|
10
|
+
return resolved;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
} catch {
|
|
14
|
+
// ignore
|
|
15
|
+
}
|
|
16
|
+
return 'en';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getIntlLocaleData(localeCode: string): LocaleData {
|
|
20
|
+
const base = enLocale;
|
|
21
|
+
try {
|
|
22
|
+
if (typeof Intl !== 'undefined' && Intl.DateTimeFormat) {
|
|
23
|
+
const months: string[] = [];
|
|
24
|
+
const monthsShort: string[] = [];
|
|
25
|
+
for (let m = 0; m < 12; m++) {
|
|
26
|
+
const d = new Date(2026, m, 1);
|
|
27
|
+
months.push(
|
|
28
|
+
new Intl.DateTimeFormat(localeCode, { month: 'long' }).format(d)
|
|
29
|
+
);
|
|
30
|
+
monthsShort.push(
|
|
31
|
+
new Intl.DateTimeFormat(localeCode, { month: 'short' }).format(d)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const weekdays: string[] = [];
|
|
36
|
+
const weekdaysShort: string[] = [];
|
|
37
|
+
const weekdaysMin: string[] = [];
|
|
38
|
+
// 2026-11-15 was Sunday
|
|
39
|
+
for (let w = 0; w < 7; w++) {
|
|
40
|
+
const d = new Date(2026, 10, 15 + w);
|
|
41
|
+
weekdays.push(
|
|
42
|
+
new Intl.DateTimeFormat(localeCode, { weekday: 'long' }).format(d)
|
|
43
|
+
);
|
|
44
|
+
weekdaysShort.push(
|
|
45
|
+
new Intl.DateTimeFormat(localeCode, { weekday: 'short' }).format(d)
|
|
46
|
+
);
|
|
47
|
+
weekdaysMin.push(
|
|
48
|
+
new Intl.DateTimeFormat(localeCode, { weekday: 'narrow' }).format(d)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
...base,
|
|
54
|
+
code: localeCode,
|
|
55
|
+
months,
|
|
56
|
+
monthsShort,
|
|
57
|
+
weekdays,
|
|
58
|
+
weekdaysShort,
|
|
59
|
+
weekdaysMin,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
} catch {
|
|
63
|
+
// fallback to base English
|
|
64
|
+
}
|
|
65
|
+
return { ...base, code: localeCode };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function resolveLocale(
|
|
69
|
+
localeInput?: string | PartialLocaleData | null
|
|
70
|
+
): LocaleData {
|
|
71
|
+
if (!localeInput) {
|
|
72
|
+
const devLocale = getDeviceLocale();
|
|
73
|
+
const langCode = devLocale.split('-')[0]?.toLowerCase() || 'en';
|
|
74
|
+
const base = BUILTIN_LOCALES[langCode] || getIntlLocaleData(devLocale);
|
|
75
|
+
return { ...base, code: devLocale };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (typeof localeInput === 'string') {
|
|
79
|
+
const langCode = localeInput.split('-')[0]?.toLowerCase() || 'en';
|
|
80
|
+
const base =
|
|
81
|
+
BUILTIN_LOCALES[langCode] ||
|
|
82
|
+
BUILTIN_LOCALES[localeInput] ||
|
|
83
|
+
getIntlLocaleData(localeInput);
|
|
84
|
+
return { ...base, code: localeInput };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// It's a custom PartialLocaleData object
|
|
88
|
+
const langCode = localeInput.code?.split('-')[0]?.toLowerCase() || 'en';
|
|
89
|
+
const base =
|
|
90
|
+
BUILTIN_LOCALES[langCode] ||
|
|
91
|
+
(localeInput.code ? getIntlLocaleData(localeInput.code) : enLocale);
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
...base,
|
|
95
|
+
...localeInput,
|
|
96
|
+
code: localeInput.code || base.code,
|
|
97
|
+
months: localeInput.months || base.months,
|
|
98
|
+
monthsShort: localeInput.monthsShort || base.monthsShort,
|
|
99
|
+
weekdays: localeInput.weekdays || base.weekdays,
|
|
100
|
+
weekdaysShort: localeInput.weekdaysShort || base.weekdaysShort,
|
|
101
|
+
weekdaysMin: localeInput.weekdaysMin || base.weekdaysMin,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function useLocale(
|
|
106
|
+
localeInput?: string | PartialLocaleData | null
|
|
107
|
+
): LocaleData {
|
|
108
|
+
return useMemo(() => resolveLocale(localeInput), [localeInput]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Format a Date using a format string and LocaleData
|
|
113
|
+
* Tokens supported:
|
|
114
|
+
* YYYY - Full year (2026)
|
|
115
|
+
* YY - 2-digit year (26)
|
|
116
|
+
* MMMM - Full month name (November / नवंबर)
|
|
117
|
+
* MMM - Short month name (Nov / नव)
|
|
118
|
+
* MM - 2-digit month (01-12)
|
|
119
|
+
* M - 1-digit month (1-12)
|
|
120
|
+
* DD - 2-digit day of month (01-31)
|
|
121
|
+
* D - 1-digit day of month (1-31)
|
|
122
|
+
* dddd - Full weekday name (Thursday / गुरुवार)
|
|
123
|
+
* ddd - Short weekday name (Thu / गुरु)
|
|
124
|
+
* dd - Min weekday name (Th / गु)
|
|
125
|
+
* HH - 24-hour padded (00-23)
|
|
126
|
+
* H - 24-hour unpadded (0-23)
|
|
127
|
+
* hh - 12-hour padded (01-12)
|
|
128
|
+
* h - 12-hour unpadded (1-12)
|
|
129
|
+
* mm - Minutes padded (00-59)
|
|
130
|
+
* m - Minutes unpadded (0-59)
|
|
131
|
+
* ss - Seconds padded (00-59)
|
|
132
|
+
* s - Seconds unpadded (0-59)
|
|
133
|
+
* A - Uppercase AM/PM from locale (AM / PM / पूर्वाह्न)
|
|
134
|
+
* a - Lowercase am/pm
|
|
135
|
+
*/
|
|
136
|
+
export function formatLocalized(
|
|
137
|
+
date: Date,
|
|
138
|
+
formatStr: string = 'YYYY-MM-DD',
|
|
139
|
+
localeInput: string | PartialLocaleData | LocaleData = enLocale
|
|
140
|
+
): string {
|
|
141
|
+
if (isNaN(date.getTime())) {
|
|
142
|
+
return '';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const locale: LocaleData =
|
|
146
|
+
typeof localeInput === 'string' ||
|
|
147
|
+
!('months' in localeInput) ||
|
|
148
|
+
!Array.isArray((localeInput as any).months)
|
|
149
|
+
? resolveLocale(localeInput as string | PartialLocaleData)
|
|
150
|
+
: (localeInput as LocaleData);
|
|
151
|
+
|
|
152
|
+
const year = date.getFullYear();
|
|
153
|
+
const month = date.getMonth(); // 0-11
|
|
154
|
+
const day = date.getDate();
|
|
155
|
+
const dayOfWeek = date.getDay(); // 0-6
|
|
156
|
+
const hours24 = date.getHours();
|
|
157
|
+
const hours12 = hours24 % 12 === 0 ? 12 : hours24 % 12;
|
|
158
|
+
const minutes = date.getMinutes();
|
|
159
|
+
const seconds = date.getSeconds();
|
|
160
|
+
const isPM = hours24 >= 12;
|
|
161
|
+
const ampm = isPM ? locale.pm : locale.am;
|
|
162
|
+
|
|
163
|
+
const pad = (n: number) => (n < 10 ? `0${n}` : `${n}`);
|
|
164
|
+
|
|
165
|
+
const replacements: Record<string, string> = {
|
|
166
|
+
YYYY: String(year),
|
|
167
|
+
YY: String(year).slice(-2),
|
|
168
|
+
MMMM: locale.months[month] || '',
|
|
169
|
+
MMM: locale.monthsShort[month] || '',
|
|
170
|
+
MM: pad(month + 1),
|
|
171
|
+
M: String(month + 1),
|
|
172
|
+
DD: pad(day),
|
|
173
|
+
D: String(day),
|
|
174
|
+
dddd: locale.weekdays[dayOfWeek] || '',
|
|
175
|
+
ddd: locale.weekdaysShort[dayOfWeek] || '',
|
|
176
|
+
dd: locale.weekdaysMin[dayOfWeek] || '',
|
|
177
|
+
HH: pad(hours24),
|
|
178
|
+
H: String(hours24),
|
|
179
|
+
hh: pad(hours12),
|
|
180
|
+
h: String(hours12),
|
|
181
|
+
mm: pad(minutes),
|
|
182
|
+
m: String(minutes),
|
|
183
|
+
ss: pad(seconds),
|
|
184
|
+
s: String(seconds),
|
|
185
|
+
A: ampm,
|
|
186
|
+
a: ampm.toLowerCase(),
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const regex =
|
|
190
|
+
/(\[[^\]]*\]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|HH|H|hh|h|mm|m|ss|s|A|a)/g;
|
|
191
|
+
return formatStr.replace(regex, (match) => {
|
|
192
|
+
if (match.startsWith('[') && match.endsWith(']')) {
|
|
193
|
+
return match.slice(1, -1);
|
|
194
|
+
}
|
|
195
|
+
return replacements[match] ?? match;
|
|
196
|
+
});
|
|
197
|
+
}
|