chronos-date 1.0.0
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/LICENSE +201 -0
- package/README.md +31 -0
- package/dist/basic-CKxaRSHQ.cjs +1 -0
- package/dist/basic-e46DaNAi.mjs +1 -0
- package/dist/constants.cjs +1 -0
- package/dist/constants.d.cts +2 -0
- package/dist/constants.d.mts +2 -0
- package/dist/constants.mjs +1 -0
- package/dist/convert-Bmp63ats.mjs +1 -0
- package/dist/convert-DrLrcgqz.cjs +1 -0
- package/dist/greet-BBsrvmkn.mjs +1 -0
- package/dist/greet-C-6mruI9.cjs +1 -0
- package/dist/guards.cjs +1 -0
- package/dist/guards.d.cts +71 -0
- package/dist/guards.d.mts +71 -0
- package/dist/guards.mjs +1 -0
- package/dist/helpers-DGzYnP81.cjs +1 -0
- package/dist/helpers-N1X_Rj_V.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -0
- package/dist/non-primitives-B2EE6D6s.mjs +1 -0
- package/dist/non-primitives-Bu3a4WL4.cjs +1 -0
- package/dist/plugins/banglaPlugin.cjs +1 -0
- package/dist/plugins/banglaPlugin.d.cts +225 -0
- package/dist/plugins/banglaPlugin.d.mts +225 -0
- package/dist/plugins/banglaPlugin.mjs +1 -0
- package/dist/plugins/businessPlugin.cjs +1 -0
- package/dist/plugins/businessPlugin.d.cts +446 -0
- package/dist/plugins/businessPlugin.d.mts +446 -0
- package/dist/plugins/businessPlugin.mjs +1 -0
- package/dist/plugins/dateRangePlugin.cjs +1 -0
- package/dist/plugins/dateRangePlugin.d.cts +71 -0
- package/dist/plugins/dateRangePlugin.d.mts +71 -0
- package/dist/plugins/dateRangePlugin.mjs +1 -0
- package/dist/plugins/dayPartPlugin.cjs +1 -0
- package/dist/plugins/dayPartPlugin.d.cts +45 -0
- package/dist/plugins/dayPartPlugin.d.mts +45 -0
- package/dist/plugins/dayPartPlugin.mjs +1 -0
- package/dist/plugins/durationPlugin.cjs +1 -0
- package/dist/plugins/durationPlugin.d.cts +30 -0
- package/dist/plugins/durationPlugin.d.mts +30 -0
- package/dist/plugins/durationPlugin.mjs +1 -0
- package/dist/plugins/fromNowPlugin.cjs +1 -0
- package/dist/plugins/fromNowPlugin.d.cts +24 -0
- package/dist/plugins/fromNowPlugin.d.mts +24 -0
- package/dist/plugins/fromNowPlugin.mjs +1 -0
- package/dist/plugins/greetingPlugin.cjs +1 -0
- package/dist/plugins/greetingPlugin.d.cts +29 -0
- package/dist/plugins/greetingPlugin.d.mts +29 -0
- package/dist/plugins/greetingPlugin.mjs +1 -0
- package/dist/plugins/palindromePlugin.cjs +1 -0
- package/dist/plugins/palindromePlugin.d.cts +38 -0
- package/dist/plugins/palindromePlugin.d.mts +38 -0
- package/dist/plugins/palindromePlugin.mjs +1 -0
- package/dist/plugins/relativeTimePlugin.cjs +1 -0
- package/dist/plugins/relativeTimePlugin.d.cts +82 -0
- package/dist/plugins/relativeTimePlugin.d.mts +82 -0
- package/dist/plugins/relativeTimePlugin.mjs +1 -0
- package/dist/plugins/roundPlugin.cjs +1 -0
- package/dist/plugins/roundPlugin.d.cts +29 -0
- package/dist/plugins/roundPlugin.d.mts +29 -0
- package/dist/plugins/roundPlugin.mjs +1 -0
- package/dist/plugins/seasonPlugin.cjs +1 -0
- package/dist/plugins/seasonPlugin.d.cts +26 -0
- package/dist/plugins/seasonPlugin.d.mts +26 -0
- package/dist/plugins/seasonPlugin.mjs +1 -0
- package/dist/plugins/timeZonePlugin.cjs +1 -0
- package/dist/plugins/timeZonePlugin.d.cts +88 -0
- package/dist/plugins/timeZonePlugin.d.mts +88 -0
- package/dist/plugins/timeZonePlugin.mjs +1 -0
- package/dist/plugins/zodiacPlugin.cjs +1 -0
- package/dist/plugins/zodiacPlugin.d.cts +41 -0
- package/dist/plugins/zodiacPlugin.d.mts +41 -0
- package/dist/plugins/zodiacPlugin.mjs +1 -0
- package/dist/primitives-Cxss_JVF.mjs +1 -0
- package/dist/primitives-Db2FUp4e.cjs +1 -0
- package/dist/seasons-ChAIVphi.mjs +1 -0
- package/dist/seasons-CioTH5Dm.d.mts +5285 -0
- package/dist/seasons-CsVeJ27s.d.cts +5285 -0
- package/dist/seasons-oABOhHcX.cjs +1 -0
- package/dist/timezone-B10UItNO.mjs +1 -0
- package/dist/timezone-CWxbK_7I.cjs +1 -0
- package/dist/types-B2fgrJ86.d.mts +2123 -0
- package/dist/types-DPTQ_yLx.d.cts +2123 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/dist/utilities-B8dOAQVD.cjs +1 -0
- package/dist/utilities-BJE06bms.mjs +1 -0
- package/dist/utilities-D2-p26DX.cjs +1 -0
- package/dist/utilities-DV_ohS37.mjs +1 -0
- package/dist/utils.cjs +1 -0
- package/dist/utils.d.cts +188 -0
- package/dist/utils.d.mts +188 -0
- package/dist/utils.mjs +1 -0
- package/package.json +162 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the license notice for easier identification
|
|
187
|
+
within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 - present Nazmul Hassan
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Chronos Date
|
|
2
|
+
|
|
3
|
+
> A comprehensive date and time library for any JavaScript and TypeScript environment.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
### NPM
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i chronos-date
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### PNPM
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add chronos-date
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### YARN
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
yarn add chronos-date
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
>[!INFO]
|
|
30
|
+
>
|
|
31
|
+
> Full Docs Coming Soon...
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Symbol(`Internals`),t=Object.freeze([`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]),n=Object.freeze([`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]),r=Object.freeze([`YYYY`,`YY`,`yyyy`,`yy`]),i=Object.freeze([`M`,`MM`,`mmm`,`mmmm`]),a=Object.freeze([`DD`,`D`,`Do`]),o=Object.freeze([`d`,`dd`,`ddd`]),s=Object.freeze([`H`,`HH`,`hh`,`h`]),c=Object.freeze([`mm`,`m`]),l=Object.freeze([`ss`,`s`]),u=Object.freeze([`ms`,`mss`]),d=Object.freeze([`a`,`A`]),f=Object.freeze([`Z`,`ZZ`,`S`,`SS`]),p=Object.freeze([...r,...i,...o,...a,...s,...c,...l,...u,...d,...f].sort((e,t)=>t.length-e.length)),m=Object.freeze({night:[`21`,`23`],midnight:[`00`,`01`],lateNight:[`02`,`04`],morning:[`05`,`11`],afternoon:[`12`,`16`],evening:[`17`,`20`]}),h=Object.freeze([[`Capricorn`,[12,22]],[`Aquarius`,[1,20]],[`Pisces`,[2,19]],[`Aries`,[3,21]],[`Taurus`,[4,20]],[`Gemini`,[5,21]],[`Cancer`,[6,21]],[`Leo`,[7,23]],[`Virgo`,[8,23]],[`Libra`,[9,23]],[`Scorpio`,[10,23]],[`Sagittarius`,[11,22]]]),g=Object.freeze([[`Capricorn`,[1,14]],[`Aquarius`,[2,13]],[`Pisces`,[3,14]],[`Aries`,[4,14]],[`Taurus`,[5,15]],[`Gemini`,[6,15]],[`Cancer`,[7,16]],[`Leo`,[8,17]],[`Virgo`,[9,17]],[`Libra`,[10,17]],[`Scorpio`,[11,16]],[`Sagittarius`,[12,16]]]),_=Object.freeze({western:h,vedic:g,tropical:h,sidereal:g}),v=Object.freeze((()=>{let e=1e3,t=e*60,n=t*60,r=n*24,i=r*7,a=r*365.25,o=a/12;return{y:a,yr:a,yrs:a,year:a,years:a,mo:o,month:o,months:o,w:i,week:i,weeks:i,d:r,day:r,days:r,h:n,hr:n,hrs:n,hour:n,hours:n,m:t,min:t,mins:t,minute:t,minutes:t,s:e,sec:e,secs:e,second:e,seconds:e,ms:1,msec:1,msecs:1,millisecond:1,milliseconds:1}})()),y=Object.freeze({"revised-2019":{normal:[31,31,31,31,31,31,30,30,30,30,29,30],leap:[31,31,31,31,31,31,30,30,30,30,30,30]},"revised-1966":{normal:[31,31,31,31,31,30,30,30,30,30,30,30],leap:[31,31,31,31,31,30,30,30,30,30,31,30]}}),b=Object.freeze([{bn:`গ্রীষ্ম`,en:`Grisma (Summer)`},{bn:`বর্ষা`,en:`Barsa (Monsoon)`},{bn:`শরৎ`,en:`Sarat (Autumn)`},{bn:`হেমন্ত`,en:`Hemanta (Late-Autumn)`},{bn:`শীত`,en:`Shhit (Winter)`},{bn:`বসন্ত`,en:`Basanta (Spring)`}]),x=Object.freeze([{bn:`রবিবার`,en:`Robibar (Sunday)`,short:`র`},{bn:`সোমবার`,en:`Shombar (Monday)`,short:`সো`},{bn:`মঙ্গলবার`,en:`Mongolbar (Tuesday)`,short:`ম`},{bn:`বুধবার`,en:`Budhbar (Wednesday)`,short:`বু`},{bn:`বৃহস্পতিবার`,en:`Brihoshpotibar (Thursday)`,short:`বৃ`},{bn:`শুক্রবার`,en:`Shukrobar (Friday)`,short:`শু`},{bn:`শনিবার`,en:`Shonibar (Saturday)`,short:`শ`}]),S=Object.freeze([{bn:`বৈশাখ`,en:`Boishakh`,short:`বৈ`},{bn:`জ্যৈষ্ঠ`,en:`Joishtho`,short:`জ্য`},{bn:`আষাঢ়`,en:`Asharh`,short:`আ`},{bn:`শ্রাবণ`,en:`Srabon`,short:`শ্রা`},{bn:`ভাদ্র`,en:`Bhadro`,short:`ভা`},{bn:`আশ্বিন`,en:`Ashwin`,short:`আ`},{bn:`কার্তিক`,en:`Kartik`,short:`কা`},{bn:`অগ্রহায়ণ`,en:`Ogrohayon`,short:`অ`},{bn:`পৌষ`,en:`Poush`,short:`পৌ`},{bn:`মাঘ`,en:`Magh`,short:`মা`},{bn:`ফাল্গুন`,en:`Falgun`,short:`ফা`},{bn:`চৈত্র`,en:`Choitro`,short:`চৈ`}]);Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return 864e5}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Symbol(`Internals`),t=864e5,n=Object.freeze([`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]),r=Object.freeze([`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]),i=Object.freeze([`YYYY`,`YY`,`yyyy`,`yy`]),a=Object.freeze([`M`,`MM`,`mmm`,`mmmm`]),o=Object.freeze([`DD`,`D`,`Do`]),s=Object.freeze([`d`,`dd`,`ddd`]),c=Object.freeze([`H`,`HH`,`hh`,`h`]),l=Object.freeze([`mm`,`m`]),u=Object.freeze([`ss`,`s`]),d=Object.freeze([`ms`,`mss`]),f=Object.freeze([`a`,`A`]),p=Object.freeze([`Z`,`ZZ`,`S`,`SS`]),m=Object.freeze([...i,...a,...s,...o,...c,...l,...u,...d,...f,...p].sort((e,t)=>t.length-e.length)),h=Object.freeze({night:[`21`,`23`],midnight:[`00`,`01`],lateNight:[`02`,`04`],morning:[`05`,`11`],afternoon:[`12`,`16`],evening:[`17`,`20`]}),g=Object.freeze([[`Capricorn`,[12,22]],[`Aquarius`,[1,20]],[`Pisces`,[2,19]],[`Aries`,[3,21]],[`Taurus`,[4,20]],[`Gemini`,[5,21]],[`Cancer`,[6,21]],[`Leo`,[7,23]],[`Virgo`,[8,23]],[`Libra`,[9,23]],[`Scorpio`,[10,23]],[`Sagittarius`,[11,22]]]),_=Object.freeze([[`Capricorn`,[1,14]],[`Aquarius`,[2,13]],[`Pisces`,[3,14]],[`Aries`,[4,14]],[`Taurus`,[5,15]],[`Gemini`,[6,15]],[`Cancer`,[7,16]],[`Leo`,[8,17]],[`Virgo`,[9,17]],[`Libra`,[10,17]],[`Scorpio`,[11,16]],[`Sagittarius`,[12,16]]]),v=Object.freeze({western:g,vedic:_,tropical:g,sidereal:_}),y=Object.freeze((()=>{let e=1e3,t=e*60,n=t*60,r=n*24,i=r*7,a=r*365.25,o=a/12;return{y:a,yr:a,yrs:a,year:a,years:a,mo:o,month:o,months:o,w:i,week:i,weeks:i,d:r,day:r,days:r,h:n,hr:n,hrs:n,hour:n,hours:n,m:t,min:t,mins:t,minute:t,minutes:t,s:e,sec:e,secs:e,second:e,seconds:e,ms:1,msec:1,msecs:1,millisecond:1,milliseconds:1}})()),b=Object.freeze({"revised-2019":{normal:[31,31,31,31,31,31,30,30,30,30,29,30],leap:[31,31,31,31,31,31,30,30,30,30,30,30]},"revised-1966":{normal:[31,31,31,31,31,30,30,30,30,30,30,30],leap:[31,31,31,31,31,30,30,30,30,30,31,30]}}),x=Object.freeze([{bn:`গ্রীষ্ম`,en:`Grisma (Summer)`},{bn:`বর্ষা`,en:`Barsa (Monsoon)`},{bn:`শরৎ`,en:`Sarat (Autumn)`},{bn:`হেমন্ত`,en:`Hemanta (Late-Autumn)`},{bn:`শীত`,en:`Shhit (Winter)`},{bn:`বসন্ত`,en:`Basanta (Spring)`}]),S=Object.freeze([{bn:`রবিবার`,en:`Robibar (Sunday)`,short:`র`},{bn:`সোমবার`,en:`Shombar (Monday)`,short:`সো`},{bn:`মঙ্গলবার`,en:`Mongolbar (Tuesday)`,short:`ম`},{bn:`বুধবার`,en:`Budhbar (Wednesday)`,short:`বু`},{bn:`বৃহস্পতিবার`,en:`Brihoshpotibar (Thursday)`,short:`বৃ`},{bn:`শুক্রবার`,en:`Shukrobar (Friday)`,short:`শু`},{bn:`শনিবার`,en:`Shonibar (Saturday)`,short:`শ`}]),C=Object.freeze([{bn:`বৈশাখ`,en:`Boishakh`,short:`বৈ`},{bn:`জ্যৈষ্ঠ`,en:`Joishtho`,short:`জ্য`},{bn:`আষাঢ়`,en:`Asharh`,short:`আ`},{bn:`শ্রাবণ`,en:`Srabon`,short:`শ্রা`},{bn:`ভাদ্র`,en:`Bhadro`,short:`ভা`},{bn:`আশ্বিন`,en:`Ashwin`,short:`আ`},{bn:`কার্তিক`,en:`Kartik`,short:`কা`},{bn:`অগ্রহায়ণ`,en:`Ogrohayon`,short:`অ`},{bn:`পৌষ`,en:`Poush`,short:`পৌ`},{bn:`মাঘ`,en:`Magh`,short:`মা`},{bn:`ফাল্গুন`,en:`Falgun`,short:`ফা`},{bn:`চৈত্র`,en:`Choitro`,short:`চৈ`}]);export{h as a,r as c,m as d,_ as f,x as i,y as l,v as m,C as n,n as o,g as p,b as r,e as s,S as t,t as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./basic-CKxaRSHQ.cjs`),t=require(`./timezone-CWxbK_7I.cjs`),n=require(`./seasons-oABOhHcX.cjs`);exports.AUSTRALIA_SEASONS=n.t,exports.BANGLADESH_SEASONS=n.n,exports.ETHIOPIA_SEASONS=n.i,exports.IANA_TZ_IDS=t.t,exports.INDIA_IMD_SEASONS=n.a,exports.INDIA_TAMIL_SEASONS=n.o,exports.INDIA_VEDIC_SEASONS=n.s,exports.JAPAN_SEASONS=n.c,exports.MONTHS=e.c,exports.NATIVE_TZ_IDS=t.n,exports.PHILIPPINES_SEASONS=n.l,exports.SEASON_PRESETS=n.u,exports.TIME_ZONES=t.r,exports.TZ_ABBREVIATIONS=t.r,exports.TIME_ZONES_NATIVE=t.i,exports.TIME_ZONE_IDS=t.a,exports.TIME_ZONE_LABELS=t.o,exports.US_ACADEMIC_SEASONS=n.d,exports.VEDIC_ZODIAC_SIGNS=e.f,exports.WEEK_DAYS=e.o,exports.WESTERN_SEASONS=n.r,exports.WESTERN_ZODIAC_SIGNS=e.p;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { L as VEDIC_ZODIAC_SIGNS, M as MONTHS, R as WESTERN_ZODIAC_SIGNS, _ as TIME_ZONE_LABELS, a as INDIA_IMD_SEASONS, c as JAPAN_SEASONS, d as US_ACADEMIC_SEASONS, f as IANA_TZ_IDS, g as TIME_ZONE_IDS, h as TIME_ZONES_NATIVE, i as ETHIOPIA_SEASONS, l as PHILIPPINES_SEASONS, m as TIME_ZONES, n as BANGLADESH_SEASONS, o as INDIA_TAMIL_SEASONS, p as NATIVE_TZ_IDS, r as DEFAULT_SEASONS, s as INDIA_VEDIC_SEASONS, t as AUSTRALIA_SEASONS, u as SEASON_PRESETS, w as DAYS } from "./seasons-CsVeJ27s.cjs";
|
|
2
|
+
export { AUSTRALIA_SEASONS, BANGLADESH_SEASONS, ETHIOPIA_SEASONS, IANA_TZ_IDS, INDIA_IMD_SEASONS, INDIA_TAMIL_SEASONS, INDIA_VEDIC_SEASONS, JAPAN_SEASONS, MONTHS, NATIVE_TZ_IDS, PHILIPPINES_SEASONS, SEASON_PRESETS, TIME_ZONES, TIME_ZONES as TZ_ABBREVIATIONS, TIME_ZONES_NATIVE, TIME_ZONE_IDS, TIME_ZONE_LABELS, US_ACADEMIC_SEASONS, VEDIC_ZODIAC_SIGNS, DAYS as WEEK_DAYS, DEFAULT_SEASONS as WESTERN_SEASONS, WESTERN_ZODIAC_SIGNS };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { L as VEDIC_ZODIAC_SIGNS, M as MONTHS, R as WESTERN_ZODIAC_SIGNS, _ as TIME_ZONE_LABELS, a as INDIA_IMD_SEASONS, c as JAPAN_SEASONS, d as US_ACADEMIC_SEASONS, f as IANA_TZ_IDS, g as TIME_ZONE_IDS, h as TIME_ZONES_NATIVE, i as ETHIOPIA_SEASONS, l as PHILIPPINES_SEASONS, m as TIME_ZONES, n as BANGLADESH_SEASONS, o as INDIA_TAMIL_SEASONS, p as NATIVE_TZ_IDS, r as DEFAULT_SEASONS, s as INDIA_VEDIC_SEASONS, t as AUSTRALIA_SEASONS, u as SEASON_PRESETS, w as DAYS } from "./seasons-CioTH5Dm.mjs";
|
|
2
|
+
export { AUSTRALIA_SEASONS, BANGLADESH_SEASONS, ETHIOPIA_SEASONS, IANA_TZ_IDS, INDIA_IMD_SEASONS, INDIA_TAMIL_SEASONS, INDIA_VEDIC_SEASONS, JAPAN_SEASONS, MONTHS, NATIVE_TZ_IDS, PHILIPPINES_SEASONS, SEASON_PRESETS, TIME_ZONES, TIME_ZONES as TZ_ABBREVIATIONS, TIME_ZONES_NATIVE, TIME_ZONE_IDS, TIME_ZONE_LABELS, US_ACADEMIC_SEASONS, VEDIC_ZODIAC_SIGNS, DAYS as WEEK_DAYS, DEFAULT_SEASONS as WESTERN_SEASONS, WESTERN_ZODIAC_SIGNS };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,f as t,o as n,p as r}from"./basic-e46DaNAi.mjs";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./timezone-B10UItNO.mjs";import{a as u,c as d,d as f,i as p,l as m,n as h,o as g,r as _,s as v,t as y,u as b}from"./seasons-ChAIVphi.mjs";export{y as AUSTRALIA_SEASONS,h as BANGLADESH_SEASONS,p as ETHIOPIA_SEASONS,l as IANA_TZ_IDS,u as INDIA_IMD_SEASONS,g as INDIA_TAMIL_SEASONS,v as INDIA_VEDIC_SEASONS,d as JAPAN_SEASONS,e as MONTHS,o as NATIVE_TZ_IDS,m as PHILIPPINES_SEASONS,b as SEASON_PRESETS,c as TIME_ZONES,c as TZ_ABBREVIATIONS,a as TIME_ZONES_NATIVE,i as TIME_ZONE_IDS,s as TIME_ZONE_LABELS,f as US_ACADEMIC_SEASONS,t as VEDIC_ZODIAC_SIGNS,n as WEEK_DAYS,_ as WESTERN_SEASONS,r as WESTERN_ZODIAC_SIGNS};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./primitives-Cxss_JVF.mjs";function t(t){if(!t)return``;if(e(t))return t.trim().replace(/\s+/g,` `);if(Array.isArray(t))return t.map(t=>e(t)?t.trim().replace(/\s+/g,` `):t);throw TypeError(`Expected string or array of strings!`,{cause:`Invalid Input Type`})}const n=e=>t(e)?.split(``)?.reverse()?.join(``);function r(e,t,n=!0){let r=Math.abs(e)===1?t:`${t}s`;return n?`${e} ${r}`:r}export{n,r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./primitives-Db2FUp4e.cjs`);function t(t){if(!t)return``;if(e.n(t))return t.trim().replace(/\s+/g,` `);if(Array.isArray(t))return t.map(t=>e.n(t)?t.trim().replace(/\s+/g,` `):t);throw TypeError(`Expected string or array of strings!`,{cause:`Invalid Input Type`})}const n=e=>t(e)?.split(``)?.reverse()?.join(``);function r(e,t,n=!0){let r=Math.abs(e)===1?t:`${t}s`;return n?`${e} ${r}`:r}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isValidTime as e}from"./guards.mjs";import{n as t,p as n}from"./utilities-DV_ohS37.mjs";function r(r){let{morningEnds:i=`11:59`,noonEnds:a=`12:59`,afternoonEnds:o=`17:59`,eveningEnds:s=`23:59`,midnightEnds:c=`02:59`,currentTime:l,appendToMsg:u=``,prependToMsg:d=``,morningMessage:f=`Good Morning!`,noonMessage:p=`Good Noon!`,afternoonMessage:m=`Good Afternoon!`,eveningMessage:h=`Good Evening!`,midnightMessage:g=`Hello, Night Owl!`,defaultMessage:_=`Greetings!`}=r||{},v,y;if(l&&e(l))[v,y]=t(l);else{let e=new Date;v=e.getHours(),y=e.getMinutes()}let b=v*60+y,x=n(i),S=n(a),C=n(o),w=n(s);return b<=n(c)?d.concat(g.concat(u)):b<=x?d.concat(f.concat(u)):b<=S?d.concat(p.concat(u)):b<=C?d.concat(m.concat(u)):b<=w?d.concat(h.concat(u)):d.concat(_.concat(u))}export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./guards.cjs`),t=require(`./utilities-B8dOAQVD.cjs`);function n(n){let{morningEnds:r=`11:59`,noonEnds:i=`12:59`,afternoonEnds:a=`17:59`,eveningEnds:o=`23:59`,midnightEnds:s=`02:59`,currentTime:c,appendToMsg:l=``,prependToMsg:u=``,morningMessage:d=`Good Morning!`,noonMessage:f=`Good Noon!`,afternoonMessage:p=`Good Afternoon!`,eveningMessage:m=`Good Evening!`,midnightMessage:h=`Hello, Night Owl!`,defaultMessage:g=`Greetings!`}=n||{},_,v;if(c&&e.isValidTime(c))[_,v]=t.n(c);else{let e=new Date;_=e.getHours(),v=e.getMinutes()}let y=_*60+v,b=t.p(r),x=t.p(i),S=t.p(a),C=t.p(o);return y<=t.p(s)?u.concat(h.concat(l)):y<=b?u.concat(d.concat(l)):y<=x?u.concat(f.concat(l)):y<=S?u.concat(p.concat(l)):y<=C?u.concat(m.concat(l)):u.concat(g.concat(l))}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
package/dist/guards.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./timezone-CWxbK_7I.cjs`),t=require(`./primitives-Db2FUp4e.cjs`),n=require(`./non-primitives-Bu3a4WL4.cjs`),r=require(`./utilities-D2-p26DX.cjs`);function i(e){return e instanceof Date}function a(e){return t.n(e)&&!isNaN(Date.parse(e))}function o(e){if(!t.n(e))return!1;let[n,i]=e.split(`:`);if(!r.a(n)||!r.a(i))return!1;let a=Number(n),o=Number(i);return a>=0&&a<=23&&o>=0&&o<=59}function s(e){return t.n(e)?/^UTC[+-]?\d{1,2}:\d{2}$/.test(e):!1}function c(n){return t.n(n)?new Set([...e.t]).has(n):!1}function l(n){return t.n(n)?new Set(e.n).has(n):!1}function u(e){let t=r.n(e);return t?t%4==0&&t%100!=0||t%400==0:!1}function d(e){return!!(e instanceof Date||n.r(e)&&(n.t(e.format)&&n.t(e.toJSON)&&n.t(e.toISOString)||n.t(e.toISO)&&n.t(e.toFormat)&&t.t(e.isValid)||n.t(e.plus)&&n.t(e.minus)&&n.t(e.equals)&&n.t(e.getClass)||n.t(e.toJSON)&&n.t(e.toString)&&[`PlainDate`,`ZonedDateTime`,`Instant`].includes(e.constructor?.name??``)))}function f(e){return t.n(e)&&/^-?\d*\.?\d+ *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.test(e)}exports.isDate=i,exports.isDateLike=d,exports.isDateString=a,exports.isLeapYear=u,exports.isNativeTimeZoneId=l,exports.isTimeWithUnit=f,exports.isValidTime=o,exports.isValidTimeZoneId=c,exports.isValidUTCOffset=s;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Cn as Numeric, Mt as TimeZoneIdNative, Ot as TimeWithUnit, Rt as UTCOffset, X as $TimeZoneIdentifier, rt as ClockTime } from "./types-DPTQ_yLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/guards.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* * Type guard to check if a value is a Date object.
|
|
6
|
+
* @param value - The value to check.
|
|
7
|
+
* @returns `true` if the value is a Date object, otherwise `false`.
|
|
8
|
+
*/
|
|
9
|
+
declare function isDate(value: unknown): value is Date;
|
|
10
|
+
/**
|
|
11
|
+
* * Type guard to check if a value is a valid date string.
|
|
12
|
+
* @param value - The value to check.
|
|
13
|
+
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
14
|
+
*/
|
|
15
|
+
declare function isDateString(value: unknown): value is string;
|
|
16
|
+
/**
|
|
17
|
+
* * Checks if the provided value is a valid time string in "HH:MM" format.
|
|
18
|
+
*
|
|
19
|
+
* @param value - The value to check.
|
|
20
|
+
* @returns `true` if the value is a valid time string, `false` otherwise.
|
|
21
|
+
*/
|
|
22
|
+
declare function isValidTime(value: unknown): value is ClockTime;
|
|
23
|
+
/**
|
|
24
|
+
* * Checks if the provided value is a valid `UTCOffset` (e.g. `UTC-01:30`).
|
|
25
|
+
*
|
|
26
|
+
* @param value - The value to check.
|
|
27
|
+
* @returns `true` if the value is a valid utc offset, `false` otherwise.
|
|
28
|
+
*/
|
|
29
|
+
declare function isValidUTCOffset(value: unknown): value is UTCOffset;
|
|
30
|
+
/**
|
|
31
|
+
* * Validates whether the provided value is a recognized IANA time zone identifier (excluding `"Factory"`), based on the {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* - Relies on a large constant map of time zone identifiers, which can increase bundle size in browser environments. Matches against `597` identifiers.
|
|
35
|
+
* - Prefer {@link isNativeTimeZoneId} when you want a lightweight, native-only validation approach. Matches against `418` identifiers.
|
|
36
|
+
*
|
|
37
|
+
* @param value Time zone identifier to validate.
|
|
38
|
+
* @returns `true` if the value is a valid IANA time zone identifier, otherwise `false`.
|
|
39
|
+
*/
|
|
40
|
+
declare function isValidTimeZoneId(value: unknown): value is $TimeZoneIdentifier;
|
|
41
|
+
/**
|
|
42
|
+
* * Validates whether the provided value is a supported time zone identifier using the native JavaScript API (`Intl.supportedValuesOf('timeZone')`).
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* - Uses only native {@link Intl} capabilities—minimal code footprint, highly performant. Matches against `418` identifiers.
|
|
46
|
+
* - Prefer {@link isValidTimeZoneId} when validation must align strictly with the full
|
|
47
|
+
* {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}. Matches against `597` identifiers.
|
|
48
|
+
*
|
|
49
|
+
* @param value Time zone identifier to validate.
|
|
50
|
+
* @returns `true` if the value is a valid native JS-supported time zone identifier, otherwise `false`.
|
|
51
|
+
*/
|
|
52
|
+
declare function isNativeTimeZoneId(value: unknown): value is TimeZoneIdNative;
|
|
53
|
+
/**
|
|
54
|
+
* * Checks if the year is a leap year.
|
|
55
|
+
*
|
|
56
|
+
* - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
|
|
57
|
+
* - For example, 2000 and 2400 are leap years, but 1900 and 2100 are not.
|
|
58
|
+
* @param year The year to check.
|
|
59
|
+
* @returns `true` if the year is a leap year, `false` otherwise.
|
|
60
|
+
*/
|
|
61
|
+
declare function isLeapYear(year: Numeric): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* * Checks if a value is a date-like object from `Date`, `Chronos`, `Moment.js`, `Day.js`, `Luxon`, `JS-Joda`, or `Temporal`
|
|
64
|
+
* @param value Value to check if it is date-like object.
|
|
65
|
+
* @returns `true` if the value is date-like object, otherwise `false`.
|
|
66
|
+
*/
|
|
67
|
+
declare function isDateLike(value: unknown): boolean;
|
|
68
|
+
/** Checks if a value represents time value (number) with different forms of {@link TimeWithUnit units} */
|
|
69
|
+
declare function isTimeWithUnit(value: unknown): value is TimeWithUnit;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { isDate, isDateLike, isDateString, isLeapYear, isNativeTimeZoneId, isTimeWithUnit, isValidTime, isValidTimeZoneId, isValidUTCOffset };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Cn as Numeric, Mt as TimeZoneIdNative, Ot as TimeWithUnit, Rt as UTCOffset, X as $TimeZoneIdentifier, rt as ClockTime } from "./types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/guards.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* * Type guard to check if a value is a Date object.
|
|
6
|
+
* @param value - The value to check.
|
|
7
|
+
* @returns `true` if the value is a Date object, otherwise `false`.
|
|
8
|
+
*/
|
|
9
|
+
declare function isDate(value: unknown): value is Date;
|
|
10
|
+
/**
|
|
11
|
+
* * Type guard to check if a value is a valid date string.
|
|
12
|
+
* @param value - The value to check.
|
|
13
|
+
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
14
|
+
*/
|
|
15
|
+
declare function isDateString(value: unknown): value is string;
|
|
16
|
+
/**
|
|
17
|
+
* * Checks if the provided value is a valid time string in "HH:MM" format.
|
|
18
|
+
*
|
|
19
|
+
* @param value - The value to check.
|
|
20
|
+
* @returns `true` if the value is a valid time string, `false` otherwise.
|
|
21
|
+
*/
|
|
22
|
+
declare function isValidTime(value: unknown): value is ClockTime;
|
|
23
|
+
/**
|
|
24
|
+
* * Checks if the provided value is a valid `UTCOffset` (e.g. `UTC-01:30`).
|
|
25
|
+
*
|
|
26
|
+
* @param value - The value to check.
|
|
27
|
+
* @returns `true` if the value is a valid utc offset, `false` otherwise.
|
|
28
|
+
*/
|
|
29
|
+
declare function isValidUTCOffset(value: unknown): value is UTCOffset;
|
|
30
|
+
/**
|
|
31
|
+
* * Validates whether the provided value is a recognized IANA time zone identifier (excluding `"Factory"`), based on the {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* - Relies on a large constant map of time zone identifiers, which can increase bundle size in browser environments. Matches against `597` identifiers.
|
|
35
|
+
* - Prefer {@link isNativeTimeZoneId} when you want a lightweight, native-only validation approach. Matches against `418` identifiers.
|
|
36
|
+
*
|
|
37
|
+
* @param value Time zone identifier to validate.
|
|
38
|
+
* @returns `true` if the value is a valid IANA time zone identifier, otherwise `false`.
|
|
39
|
+
*/
|
|
40
|
+
declare function isValidTimeZoneId(value: unknown): value is $TimeZoneIdentifier;
|
|
41
|
+
/**
|
|
42
|
+
* * Validates whether the provided value is a supported time zone identifier using the native JavaScript API (`Intl.supportedValuesOf('timeZone')`).
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* - Uses only native {@link Intl} capabilities—minimal code footprint, highly performant. Matches against `418` identifiers.
|
|
46
|
+
* - Prefer {@link isValidTimeZoneId} when validation must align strictly with the full
|
|
47
|
+
* {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}. Matches against `597` identifiers.
|
|
48
|
+
*
|
|
49
|
+
* @param value Time zone identifier to validate.
|
|
50
|
+
* @returns `true` if the value is a valid native JS-supported time zone identifier, otherwise `false`.
|
|
51
|
+
*/
|
|
52
|
+
declare function isNativeTimeZoneId(value: unknown): value is TimeZoneIdNative;
|
|
53
|
+
/**
|
|
54
|
+
* * Checks if the year is a leap year.
|
|
55
|
+
*
|
|
56
|
+
* - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
|
|
57
|
+
* - For example, 2000 and 2400 are leap years, but 1900 and 2100 are not.
|
|
58
|
+
* @param year The year to check.
|
|
59
|
+
* @returns `true` if the year is a leap year, `false` otherwise.
|
|
60
|
+
*/
|
|
61
|
+
declare function isLeapYear(year: Numeric): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* * Checks if a value is a date-like object from `Date`, `Chronos`, `Moment.js`, `Day.js`, `Luxon`, `JS-Joda`, or `Temporal`
|
|
64
|
+
* @param value Value to check if it is date-like object.
|
|
65
|
+
* @returns `true` if the value is date-like object, otherwise `false`.
|
|
66
|
+
*/
|
|
67
|
+
declare function isDateLike(value: unknown): boolean;
|
|
68
|
+
/** Checks if a value represents time value (number) with different forms of {@link TimeWithUnit units} */
|
|
69
|
+
declare function isTimeWithUnit(value: unknown): value is TimeWithUnit;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { isDate, isDateLike, isDateString, isLeapYear, isNativeTimeZoneId, isTimeWithUnit, isValidTime, isValidTimeZoneId, isValidUTCOffset };
|
package/dist/guards.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./timezone-B10UItNO.mjs";import{n,t as r}from"./primitives-Cxss_JVF.mjs";import{r as i,t as a}from"./non-primitives-B2EE6D6s.mjs";import{a as o,n as s}from"./utilities-BJE06bms.mjs";function c(e){return e instanceof Date}function l(e){return n(e)&&!isNaN(Date.parse(e))}function u(e){if(!n(e))return!1;let[t,r]=e.split(`:`);if(!o(t)||!o(r))return!1;let i=Number(t),a=Number(r);return i>=0&&i<=23&&a>=0&&a<=59}function d(e){return n(e)?/^UTC[+-]?\d{1,2}:\d{2}$/.test(e):!1}function f(e){return n(e)?new Set([...t]).has(e):!1}function p(t){return n(t)?new Set(e).has(t):!1}function m(e){let t=s(e);return t?t%4==0&&t%100!=0||t%400==0:!1}function h(e){return!!(e instanceof Date||i(e)&&(a(e.format)&&a(e.toJSON)&&a(e.toISOString)||a(e.toISO)&&a(e.toFormat)&&r(e.isValid)||a(e.plus)&&a(e.minus)&&a(e.equals)&&a(e.getClass)||a(e.toJSON)&&a(e.toString)&&[`PlainDate`,`ZonedDateTime`,`Instant`].includes(e.constructor?.name??``)))}function g(e){return n(e)&&/^-?\d*\.?\d+ *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.test(e)}export{c as isDate,h as isDateLike,l as isDateString,m as isLeapYear,p as isNativeTimeZoneId,g as isTimeWithUnit,u as isValidTime,f as isValidTimeZoneId,d as isValidUTCOffset};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./basic-CKxaRSHQ.cjs`),t=require(`./primitives-Db2FUp4e.cjs`),n=require(`./non-primitives-Bu3a4WL4.cjs`),r=require(`./utilities-D2-p26DX.cjs`),i=require(`./guards.cjs`);function a(t,n){let r=RegExp(`^(${e.d.join(`|`)})`),i=``,a=0;for(;a<t.length;){if(t[a]===`[`){let e=t.indexOf(`]`,a);if(e!==-1){i+=t.slice(a+1,e),a=e+1;continue}}let e=r.exec(t.slice(a));e?(i+=n[e[0]]??e[0],a+=e[0].length):(i+=t[a],a++)}return i}function o(t,n,i,o,s,c,l,u,d,f){let p=v(n,4);return a(t,{YYYY:p,YY:p.slice(-2),yyyy:p,yy:p.slice(-2),M:String(i+1),MM:v(i+1),mmm:e.c[i].slice(0,3),mmmm:e.c[i],d:e.o[o].slice(0,2),dd:e.o[o].slice(0,3),ddd:e.o[o],D:String(s),DD:v(s),Do:r.t(s),H:String(c),HH:v(c),h:String(c%12||12),hh:v(c%12||12),m:String(l),mm:v(l),s:String(u),ss:v(u),ms:String(d),mss:v(d,3),a:c<12?`am`:`pm`,A:c<12?`AM`:`PM`,Z:f,ZZ:f})}function s(e){return e.replace(/([+-]\d{2})(?!:)/,`$1:00`)}function c(e,t,n){try{return new Intl.DateTimeFormat(`en`,{timeZone:e,timeZoneName:t}).formatToParts(n).find(e=>e.type===`timeZoneName`)?.value}catch{return}}function l(e){return e===`GMT`?`UTC+00:00`:e?.replace(/^GMT/,`UTC`)}function u(t,n){let r=e.i[Math.floor(t/2)];return n===`en`?r.en:r.bn}function d(e,t,n){return n===`revised-1966`?e%4==2:i.isLeapYear(t)}function f(e){let t=e.getMonth();return{gy:e.getFullYear(),$gm:t,gm:t+1,gd:e.getDate(),wd:e.getDay()}}function p(e){let{gy:t,gm:n,gd:r}=f(e);return n<4||n===4&&r<14?t-1:t}function m(e){return p(e)-593}function h(e){let{gy:t,$gm:n,gd:r}=f(e);return Date.UTC(t,n,r)}function g(t){return Math.floor((h(t)-Date.UTC(p(t),3,14))/e.u)}function _(t,n){let r=n??`revised-2019`,i=d(m(t),t.getFullYear(),r)?e.r?.[r].leap:e.r?.[r].normal,a=g(t),o=0;for(;a>=i[o];)a-=i[o],o++;return{days:a,monthIdx:o}}function v(e,t=2){return String(e).padStart(t,`0`)}function y(e,t=2){return e.padStart(t,`০`)}function b(e){return i.isDate(e)?e:new Date(t.i(e)?e.replace(/['"]/g,``):e??Date.now())}function x(e){return n.i(e,[`origin`,`native`,`utcOffset`,`timeZoneName`,`timeZoneId`])&&t.n(e.origin)&&(i.isDate(e.native)||i.isDateString(e.native))&&i.isValidUTCOffset(e.utcOffset)&&t.n(e.timeZoneName)&&(t.n(e.timeZoneId)||n.a(e.timeZoneId))}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return s}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,d as t,i as n,o as r,r as i,u as a}from"./basic-e46DaNAi.mjs";import{i as o,n as s}from"./primitives-Cxss_JVF.mjs";import{a as c,i as l}from"./non-primitives-B2EE6D6s.mjs";import{t as u}from"./utilities-BJE06bms.mjs";import{isDate as d,isDateString as f,isLeapYear as p,isValidUTCOffset as m}from"./guards.mjs";function h(e,n){let r=RegExp(`^(${t.join(`|`)})`),i=``,a=0;for(;a<e.length;){if(e[a]===`[`){let t=e.indexOf(`]`,a);if(t!==-1){i+=e.slice(a+1,t),a=t+1;continue}}let t=r.exec(e.slice(a));t?(i+=n[t[0]]??t[0],a+=t[0].length):(i+=e[a],a++)}return i}function g(t,n,i,a,o,s,c,l,d,f){let p=O(n,4);return h(t,{YYYY:p,YY:p.slice(-2),yyyy:p,yy:p.slice(-2),M:String(i+1),MM:O(i+1),mmm:e[i].slice(0,3),mmmm:e[i],d:r[a].slice(0,2),dd:r[a].slice(0,3),ddd:r[a],D:String(o),DD:O(o),Do:u(o),H:String(s),HH:O(s),h:String(s%12||12),hh:O(s%12||12),m:String(c),mm:O(c),s:String(l),ss:O(l),ms:String(d),mss:O(d,3),a:s<12?`am`:`pm`,A:s<12?`AM`:`PM`,Z:f,ZZ:f})}function _(e){return e.replace(/([+-]\d{2})(?!:)/,`$1:00`)}function v(e,t,n){try{return new Intl.DateTimeFormat(`en`,{timeZone:e,timeZoneName:t}).formatToParts(n).find(e=>e.type===`timeZoneName`)?.value}catch{return}}function y(e){return e===`GMT`?`UTC+00:00`:e?.replace(/^GMT/,`UTC`)}function b(e,t){let r=n[Math.floor(e/2)];return t===`en`?r.en:r.bn}function x(e,t,n){return n===`revised-1966`?e%4==2:p(t)}function S(e){let t=e.getMonth();return{gy:e.getFullYear(),$gm:t,gm:t+1,gd:e.getDate(),wd:e.getDay()}}function C(e){let{gy:t,gm:n,gd:r}=S(e);return n<4||n===4&&r<14?t-1:t}function w(e){return C(e)-593}function T(e){let{gy:t,$gm:n,gd:r}=S(e);return Date.UTC(t,n,r)}function E(e){return Math.floor((T(e)-Date.UTC(C(e),3,14))/a)}function D(e,t){let n=t??`revised-2019`,r=x(w(e),e.getFullYear(),n)?i?.[n].leap:i?.[n].normal,a=E(e),o=0;for(;a>=r[o];)a-=r[o],o++;return{days:a,monthIdx:o}}function O(e,t=2){return String(e).padStart(t,`0`)}function k(e,t=2){return e.padStart(t,`০`)}function A(e){return d(e)?e:new Date(o(e)?e.replace(/['"]/g,``):e??Date.now())}function j(e){return l(e,[`origin`,`native`,`utcOffset`,`timeZoneName`,`timeZoneId`])&&s(e.origin)&&(d(e.native)||f(e.native))&&m(e.utcOffset)&&s(e.timeZoneName)&&(s(e.timeZoneId)||c(e.timeZoneId))}export{b as a,j as c,k as d,O as f,h as i,x as l,A as n,w as o,v as p,g as r,y as s,D as t,_ as u};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./basic-CKxaRSHQ.cjs`),t=require(`./primitives-Db2FUp4e.cjs`),n=require(`./non-primitives-Bu3a4WL4.cjs`),r=require(`./guards.cjs`),i=require(`./helpers-DGzYnP81.cjs`),a=require(`./utilities-B8dOAQVD.cjs`),o=(e,n,r,i,a,o,s)=>t.r(e)&&t.r(n)?new l(e,n,r??1,i??0,a??0,o??0,s??0):new l(e);function s(e){return e in l&&e!==`prototype`&&e!==`name`&&e!==`length`&&n.t(l[e])}const c=new Proxy(o,{get(e,t,n){return t in e?Reflect.get(e,t,n):s(t)?l[t]:Reflect.get(e,t,n)},has(e,t){return t in e||s(t)}});var l=class n{#e;#t;#n;static#r=new Set;static[e.s]={internalDate(e){return e.#e},offset(e){return e.#t},withOrigin(e,t,n,r,i,a){return e.#o(t,n,r,i,a)},toNewDate(e,t){return e.#a(t)},cast(e){return n.#u(e)}};origin;native;utcOffset;timeZoneName;timeZoneId;$tzTracker;constructor(e,n,r,i,a,o,s){t.r(e)&&t.r(n)?(this.#e=new Date(e,n-1,r??1,i??0,a??0,o??0,s??0),this.native=this.#e):(this.#e=this.#a(e),this.native=this.#e),this.#n=`root`,this.origin=this.#n,this.#t=`UTC${this.getUTCOffset()}`,this.utcOffset=this.#t,this.timeZoneName=this.$getNativeTimeZoneName(),this.timeZoneId=this.$getNativeTimeZoneId()}*[Symbol.iterator](){yield[`year`,this.year],yield[`month`,this.month],yield[`isoMonth`,this.isoMonth],yield[`date`,this.date],yield[`weekDay`,this.weekDay],yield[`isoWeekDay`,this.isoWeekDay],yield[`hour`,this.hour],yield[`minute`,this.minute],yield[`second`,this.second],yield[`millisecond`,this.millisecond],yield[`timestamp`,this.getTimeStamp()],yield[`unix`,this.unix]}[Symbol.toPrimitive](e){return e===`number`?this.getTimeStamp():this.toLocalISOString()}[Symbol.replace](e,t){return e.replace(this.#l(),t)}[Symbol.search](e){return e.indexOf(this.#l())}[Symbol.split](e){return e.split(this.#l())}[Symbol.match](e){let[t,n]=this.toLocalISOString().split(`.`)[0].split(`T`),r=t.replace(/-/g,`[-/]?`),i=n?.replace(/:/g,`[:.]?`),a=n?`${r}(?:[T ]?${i})?`:r;return e.match(new RegExp(a))}get[Symbol.toStringTag](){return this.toLocalISOString()}get[Symbol.isConcatSpreadable](){return!0}$getNativeTimeZoneName(e){let t=e||a.l();return i.p(t,`long`,this.#e)??t}$getNativeTimeZoneId(){return a.l()}get#i(){return this.#e.getTime()}#a(e){let t=e instanceof n?e.toDate():i.n(e);if(isNaN(t.getTime()))throw Error(`Provided date is invalid!`);return t}#o(e,t,r,i,a){let o=new n(this.#e);return o.#n=e,o.origin=e,t&&(o.#t=t,o.utcOffset=t),r&&(o.timeZoneName=r),i&&(o.timeZoneId=i),a&&(o.$tzTracker=a),o.native=o.toDate(),o}#s(e,t){return e.#o(t,this.#t,this.timeZoneName,this.timeZoneId,this.$tzTracker)}#c(e,t=!1){let n=this.#e,r=this.toDate(),a=e=>t?r[`getUTC${e}`]():n[`get${e}`]();return i.r(e,a(`FullYear`),a(`Month`),a(`Day`),a(`Date`),a(`Hours`),a(`Minutes`),a(`Seconds`),a(`Milliseconds`),t?`Z`:this.getTimeZoneOffset())}#l(e=!0){let t=/\.\d+(Z|[+-]\d{2}:\d{2})?$/;return e?this.toLocalISOString().replace(t,``):this.toISOString().replace(t,``)}get year(){return this.#e.getFullYear()}get month(){return this.#e.getMonth()}get date(){return this.#e.getDate()}get weekDay(){return this.#e.getDay()}get hour(){return this.#e.getHours()}get minute(){return this.#e.getMinutes()}get second(){return this.#e.getSeconds()}get millisecond(){return this.#e.getMilliseconds()}get isoWeekDay(){let e=this.weekDay;return e===0?7:e}get isoMonth(){return this.month+1}get unix(){return Math.floor(this.getTimeStamp()/1e3)}get timestamp(){return this.getTimeStamp()}get lastDateOfMonth(){return this.daysInMonth()}inspect(){return`[Chronos ${this.toLocalISOString()}]`}toJSON(){return this.toLocalISOString()}valueOf(){return this.getTimeStamp()}clone(){return new n(this.#e).#o(this.#n,this.#t,this.timeZoneName,this.timeZoneId,this.$tzTracker)}toDate(){let e=(a.r(this.#t)-this.getUTCOffsetMinutes())*6e4;return new Date(this.#i-e)}toString(){return this.#c(`dd mmm DD YYYY HH:mm:ss `).concat(this.#t.replace(`UTC`,`GMT`).replace(`:`,``)).concat(` (${this.timeZoneName})`)}toLocalISOString(){return this.#c(`YYYY-MM-DDTHH:mm:ss.mssZZ`)}toISOString(){return this.toDate().toISOString()}toLocaleString(e,t){return this.#e.toLocaleString(e,t)}getTimeStamp(){return this.toDate().getTime()}format(e,t=!1){return this.#c(e||`dd, mmm DD, YYYY HH:mm:ss`,t)}formatStrict(e,t=!1){return this.#c(e||`dd, mmm DD, YYYY HH:mm:ss`,t)}formatUTC(e=`dd, mmm DD, YYYY HH:mm:ss:mss`){return this.#c(e,!0)}addSeconds(e){return this.#s(this.add(e,`second`),`addSeconds`)}addMinutes(e){return this.#s(this.add(e,`minute`),`addMinutes`)}addHours(e){return this.#s(this.add(e,`hour`),`addHours`)}addDays(e){return this.#s(this.add(e,`day`),`addDays`)}addWeeks(e){return this.#s(this.add(e,`week`),`addWeeks`)}addMonths(e){return this.#s(this.add(e,`month`),`addMonths`)}addYears(e){return this.#s(this.add(e,`year`),`addYears`)}isLeapYear(e){return r.isLeapYear(e??this.year)}isEqual(e){return this.#i===n.#u(e).#i}isEqualOrBefore(e){return this.#i<=n.#u(e).#i}isEqualOrAfter(e){return this.#i>=n.#u(e).#i}isSame(e,t,r=0){return this.startOf(t,r).#i===n.#u(e).startOf(t,r).#i}isBefore(e,t,r=0){return this.startOf(t,r).#i<n.#u(e).startOf(t,r).#i}isAfter(e,t,r=0){return this.startOf(t,r).#i>n.#u(e).startOf(t,r).#i}isSameOrBefore(e,t,n=0){return this.isSame(e,t,n)||this.isBefore(e,t,n)}isSameOrAfter(e,t,n=0){return this.isSame(e,t,n)||this.isAfter(e,t,n)}isBetween(e,t,r=`()`){let i=n.#u(e).getTimeStamp(),a=n.#u(t).getTimeStamp(),o=this.getTimeStamp();switch(r){case`[]`:return o>=i&&o<=a;case`[)`:return o>=i&&o<a;case`(]`:return o>i&&o<=a;case`()`:return o>i&&o<a;default:return!1}}isDST(){let e=this.year,t=new Date(e,0,1).getTimezoneOffset(),n=new Date(e,6,1).getTimezoneOffset();return this.#e.getTimezoneOffset()<Math.max(t,n)}isFirstDayOfMonth(){return this.isSame(this.firstDayOfMonth(),`day`)}isLastDayOfMonth(){return this.isSame(this.lastDayOfMonth(),`day`)}firstDayOfMonth(){let e=new Date(this.year,this.month,1);return this.#s(new n(e),`firstDayOfMonth`)}lastDayOfMonth(){let e=new Date(this.year,this.month+1,0);return this.#s(new n(e),`lastDayOfMonth`)}startOf(e,t=0){let r=new Date(this.#e);switch(e){case`year`:r.setMonth(0,1),r.setHours(0,0,0,0);break;case`month`:r.setDate(1),r.setHours(0,0,0,0);break;case`week`:{let e=(r.getDay()-t+7)%7;r.setDate(r.getDate()-e),r.setHours(0,0,0,0);break}case`day`:r.setHours(0,0,0,0);break;case`hour`:r.setMinutes(0,0,0);break;case`minute`:r.setSeconds(0,0);break;case`second`:r.setMilliseconds(0);break;case`millisecond`:break}return this.#s(new n(r),`startOf`)}endOf(e,t=0){let n=this.startOf(e,t).add(1,e).add(-1,`millisecond`);return this.#s(n,`endOf`)}add(e,t){let r=new Date(this.#e);switch(t){case`millisecond`:r.setMilliseconds(r.getMilliseconds()+e);break;case`second`:r.setSeconds(r.getSeconds()+e);break;case`minute`:r.setMinutes(r.getMinutes()+e);break;case`hour`:r.setHours(r.getHours()+e);break;case`day`:r.setDate(r.getDate()+e);break;case`week`:r.setDate(r.getDate()+e*7);break;case`month`:r.setMonth(r.getMonth()+e);break;case`year`:r.setFullYear(r.getFullYear()+e);break}return this.#s(new n(r),`add`)}subtract(e,t){return this.#s(this.add(-e,t),`subtract`)}get(e){switch(e){case`year`:return this.year;case`month`:return this.isoMonth;case`day`:return this.date;case`week`:return this.getWeek();case`hour`:return this.hour;case`minute`:return this.minute;case`second`:return this.second;case`millisecond`:return this.millisecond}}set(e,t){let r=new Date(this.#e);switch(e){case`year`:r.setFullYear(t);break;case`month`:r.setMonth(t-1);break;case`day`:r.setDate(t);break;case`week`:return this.setWeek(t);case`hour`:r.setHours(t);break;case`minute`:r.setMinutes(t);break;case`second`:r.setSeconds(t);break;case`millisecond`:r.setMilliseconds(t);break}return this.#s(new n(r),`set`)}diff(e,t){let r=n.#u(e),i=this.#i-r.#i;switch(t){case`millisecond`:return i;case`second`:return i/1e3;case`minute`:return i/6e4;case`hour`:return i/36e5;case`day`:return i/864e5;case`week`:return i/6048e5;case`month`:{let e=this.year-r.year,t=this.month-r.month;return e*12+t+(this.date-r.date)/this.daysInMonth()}case`year`:return this.diff(r,`month`)/12}}calendar(e){let t=e?n.#u(e):new n,r=this.startOf(`day`),i=t.startOf(`day`),a=r.diff(i,`day`),o=this.toDate().toLocaleString(`en`,{hour:`numeric`,minute:`2-digit`});return a===0?`Today at ${o}`:a===1?`Tomorrow at ${o}`:a===-1?`Yesterday at ${o}`:this.toDate().toLocaleString(`en`,{month:`long`,day:`2-digit`,year:`numeric`,weekday:`long`,hour:`numeric`,minute:`2-digit`})}fromNowShort(){let e=new n,t=this.diff(e,`second`),r=Math.abs(t),i=t>=0?`in `:``,a=t<0?` ago`:``;return r<60?`${i}${Math.floor(r)}s${a}`:r<3600?`${i}${Math.floor(r/60)}m${a}`:r<86400?`${i}${Math.floor(r/3600)}h${a}`:r<2592e3?`${i}${Math.floor(r/86400)}d${a}`:r<31536e3?`${i}${Math.floor(r/2592e3)}mo${a}`:`${i}${Math.floor(r/31536e3)}y${a}`}setWeek(e){let t=new Date(this.#e),r=t.getFullYear(),i=new Date(r,0,4),a=i.getDay()||7,o=new Date(i);return o.setDate(i.getDate()-(a-1)),o.setDate(o.getDate()+(e-1)*7),t.setFullYear(o.getFullYear()),t.setMonth(o.getMonth()),t.setDate(o.getDate()),this.#s(new n(t),`setWeek`)}getWeek(){let e=this.startOf(`week`,1).add(3,`day`),t=new n(e.year,1,4).startOf(`week`,1).add(3,`day`);return e.diff(t,`week`)+1}getWeekOfYear(e=0){let t=this.startOf(`year`).startOf(`week`,e);return this.startOf(`week`,e).diff(t,`week`)+1}getWeekYear(e=0){return this.startOf(`week`,e).add(3,`day`).year}getDayOfYear(){return this.startOf(`day`).diff(this.startOf(`year`),`day`)+1}daysInMonth(){return new Date(this.year,this.month+1,0).getDate()}toObject(){return Object.fromEntries([...this])}toArray(){return Object.values(this.toObject())}toQuarter(){let e=this.#e.getMonth();return Math.floor(e/3)+1}getUTCOffset(){let e=-this.#e.getTimezoneOffset(),t=e>=0?`+`:`-`,n=e=>String(Math.floor(Math.abs(e))).padStart(2,`0`);return`${t}${n(e/60)}:${n(e%60)}`}getTimeZoneOffset(){return this.#t.replace(`UTC`,``)}getUTCOffsetMinutes(){return-this.#e.getTimezoneOffset()}getTimeZoneOffsetMinutes(){return a.r(this.#t)}toUTC(){let e=this.getTimeZoneOffsetMinutes();return new n(new Date(this.#i-e*60*1e3)).#o(`toUTC`,`UTC+00:00`,`Greenwich Mean Time`,`UTC`)}toLocal(){let e=this.getTimeZoneOffsetMinutes()-this.getUTCOffsetMinutes();return new n(new Date(this.#i-e*60*1e3)).#o(`toLocal`)}day(t){return e.o[t??this.weekDay]}monthName(t){return e.c[t??this.month]}static parse(e,t){let r={YYYY:`(?<YYYY>\\d{4})`,YY:`(?<YY>\\d{2})`,MM:`(?<MM>\\d{2})`,M:`(?<M>\\d{1,2})`,DD:`(?<DD>\\d{2})`,D:`(?<D>\\d{1,2})`,HH:`(?<HH>\\d{2})`,H:`(?<H>\\d{1,2})`,mm:`(?<mm>\\d{2})`,m:`(?<m>\\d{1,2})`,ss:`(?<ss>\\d{2})`,s:`(?<s>\\d{1,2})`,mss:`(?<mss>\\d{3})`,ms:`(?<ms>\\d{1,3})`},i={YYYY:`year`,YY:`year`,MM:`month`,M:`month`,DD:`date`,D:`date`,HH:`hour`,H:`hour`,mm:`minute`,m:`minute`,ss:`second`,s:`second`,mss:`millisecond`,ms:`millisecond`},a=new RegExp(Object.keys(r).sort((e,t)=>t.length-e.length).join(`|`),`g`),o=t?.trim()?.replace(a,e=>r[e]??e)?.replace(/\s+/g,`\\s*`),s=RegExp(`^${o}\\s*$`).exec(e.trim());if(!s?.groups)throw Error(`Invalid date format!`);let c={};for(let[e,t]of Object.entries(s.groups)){let n=i[e];if(n){let r=Number(t);e===`YY`&&(r+=r<100?2e3:0),c[n]=r}}return new n(c?.year??1970,c?.month??1,c?.date??1,c?.hour??0,c?.minute??0,c?.second??0,c?.millisecond??0).#o(`parse`)}static with(e){let t=new n,{year:r,month:i,date:a,hour:o,minute:s,second:c,millisecond:l}=e??{},u=()=>t.startOf(`month`).set(`year`,r??t.year).set(`month`,i??t.isoMonth).lastDateOfMonth;return new n(r??t.year,i??t.isoMonth,a||(t.isLastDayOfMonth()&&t.date>=u()?u():t.date),o??t.hour,s??t.minute,c??t.second,l??t.millisecond).#o(`with`)}static today(e){let{format:t=`dd, mmm DD, YYYY HH:mm:ss`,useUTC:r=!1}=e||{};return new n().#c(t,r)}static yesterday(){let e=new Date;return new n(e.setDate(e.getDate()-1)).#o(`yesterday`)}static tomorrow(){let e=new Date;return new n(e.setDate(e.getDate()+1)).#o(`tomorrow`)}static now(){return Date.now()}static utc(e){let t=new n(e),r=t.getTimeZoneOffsetMinutes();return new n(new Date(t.#i-r*60*1e3)).#o(`utc`,`UTC+00:00`,`Greenwich Mean Time`,`UTC`)}static formatTimePart(e,t){return new n(`${new n().#c(`YYYY-MM-DD`)}T${i.u(e)}`).#c(t||`hh:mm:ss a`)}static getDatesForDay(t,r){let i=new n,a=i.addWeeks(4),{format:o=`local`,roundDate:s=!1}=r??{};if(r){if(`from`in r||`to`in r)r?.from&&(i=n.#u(r?.from)),r?.to&&(a=n.#u(r?.to));else if(`span`in r||`unit`in r){let{span:e=4,unit:t=`week`}=r??{};a=i.add(e,t)}}s&&(i=i.startOf(`day`),a=a.startOf(`day`));let c=[],l=(i.isBefore(a,`day`)?1:-1)*e.u,u=Math.abs(a.diff(i,`day`)),d=i.#i,f=0;for(;new Date(d+f*l).getDay()!==e.o.indexOf(t);)f++;for(let e=f;e<=u;e+=7){let t=new n(d+e*l).#o(`clone`,i.#t,i.timeZoneName,i.timeZoneId,i.$tzTracker);c.push(o===`local`?t.toLocalISOString():t.toISOString())}return c}static min(...e){let t=n.#u(e[0]);for(let r of e){let e=n.#u(r);e.getTimeStamp()<t.getTimeStamp()&&(t=e)}return t.#s(t,t.#n===`root`?`min`:t.#n)}static max(...e){let t=n.#u(e[0]);for(let r of e){let e=n.#u(r);e.getTimeStamp()>t.getTimeStamp()&&(t=e)}return t.#s(t,t.#n===`root`?`max`:t.#n)}static isLeapYear(e){let i;return i=t.r(e)?e>0&&e<=9999?e:new Date(e).getFullYear():n.#u(e).year,r.isLeapYear(i)}static isValidDate(e){return e instanceof Date}static isDateString(e){return t.i(e)&&!isNaN(Date.parse(e))}static isValidChronos(e){return e instanceof n}static isReconstructable(e){return i.c(e)}static reconstruct(e){if(!i.c(e))throw TypeError(`Invalid input for reconstruction!`);let{native:t,origin:r,utcOffset:o,timeZoneName:s,timeZoneId:c,$tzTracker:l}=e,u=a.r(o),d=new n(t),f=d.getTimeZoneOffsetMinutes()-u;return(d.utcOffset===o?d:d.add(-f,`minute`)).#o(r,o,s,c,l)}static use(e){n.#r.has(e)||(n.#r.add(e),e(n))}static register(e){n.use(e)}static#u(e){return e instanceof n?e:new n(e)}};exports.Chronos=l,exports.INTERNALS=e.s,exports.chronos=c;
|
package/dist/index.d.cts
ADDED
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,o as t,s as n,u as r}from"./basic-e46DaNAi.mjs";import{i,r as a}from"./primitives-Cxss_JVF.mjs";import{t as o}from"./non-primitives-B2EE6D6s.mjs";import{isLeapYear as s}from"./guards.mjs";import{c,n as l,p as u,r as d,u as f}from"./helpers-N1X_Rj_V.mjs";import{l as p,r as m}from"./utilities-DV_ohS37.mjs";const h=(e,t,n,r,i,o,s)=>a(e)&&a(t)?new v(e,t,n??1,r??0,i??0,o??0,s??0):new v(e);function g(e){return e in v&&e!==`prototype`&&e!==`name`&&e!==`length`&&o(v[e])}const _=new Proxy(h,{get(e,t,n){return t in e?Reflect.get(e,t,n):g(t)?v[t]:Reflect.get(e,t,n)},has(e,t){return t in e||g(t)}});var v=class o{#e;#t;#n;static#r=new Set;static[n]={internalDate(e){return e.#e},offset(e){return e.#t},withOrigin(e,t,n,r,i,a){return e.#o(t,n,r,i,a)},toNewDate(e,t){return e.#a(t)},cast(e){return o.#u(e)}};origin;native;utcOffset;timeZoneName;timeZoneId;$tzTracker;constructor(e,t,n,r,i,o,s){a(e)&&a(t)?(this.#e=new Date(e,t-1,n??1,r??0,i??0,o??0,s??0),this.native=this.#e):(this.#e=this.#a(e),this.native=this.#e),this.#n=`root`,this.origin=this.#n,this.#t=`UTC${this.getUTCOffset()}`,this.utcOffset=this.#t,this.timeZoneName=this.$getNativeTimeZoneName(),this.timeZoneId=this.$getNativeTimeZoneId()}*[Symbol.iterator](){yield[`year`,this.year],yield[`month`,this.month],yield[`isoMonth`,this.isoMonth],yield[`date`,this.date],yield[`weekDay`,this.weekDay],yield[`isoWeekDay`,this.isoWeekDay],yield[`hour`,this.hour],yield[`minute`,this.minute],yield[`second`,this.second],yield[`millisecond`,this.millisecond],yield[`timestamp`,this.getTimeStamp()],yield[`unix`,this.unix]}[Symbol.toPrimitive](e){return e===`number`?this.getTimeStamp():this.toLocalISOString()}[Symbol.replace](e,t){return e.replace(this.#l(),t)}[Symbol.search](e){return e.indexOf(this.#l())}[Symbol.split](e){return e.split(this.#l())}[Symbol.match](e){let[t,n]=this.toLocalISOString().split(`.`)[0].split(`T`),r=t.replace(/-/g,`[-/]?`),i=n?.replace(/:/g,`[:.]?`),a=n?`${r}(?:[T ]?${i})?`:r;return e.match(new RegExp(a))}get[Symbol.toStringTag](){return this.toLocalISOString()}get[Symbol.isConcatSpreadable](){return!0}$getNativeTimeZoneName(e){let t=e||p();return u(t,`long`,this.#e)??t}$getNativeTimeZoneId(){return p()}get#i(){return this.#e.getTime()}#a(e){let t=e instanceof o?e.toDate():l(e);if(isNaN(t.getTime()))throw Error(`Provided date is invalid!`);return t}#o(e,t,n,r,i){let a=new o(this.#e);return a.#n=e,a.origin=e,t&&(a.#t=t,a.utcOffset=t),n&&(a.timeZoneName=n),r&&(a.timeZoneId=r),i&&(a.$tzTracker=i),a.native=a.toDate(),a}#s(e,t){return e.#o(t,this.#t,this.timeZoneName,this.timeZoneId,this.$tzTracker)}#c(e,t=!1){let n=this.#e,r=this.toDate(),i=e=>t?r[`getUTC${e}`]():n[`get${e}`]();return d(e,i(`FullYear`),i(`Month`),i(`Day`),i(`Date`),i(`Hours`),i(`Minutes`),i(`Seconds`),i(`Milliseconds`),t?`Z`:this.getTimeZoneOffset())}#l(e=!0){let t=/\.\d+(Z|[+-]\d{2}:\d{2})?$/;return e?this.toLocalISOString().replace(t,``):this.toISOString().replace(t,``)}get year(){return this.#e.getFullYear()}get month(){return this.#e.getMonth()}get date(){return this.#e.getDate()}get weekDay(){return this.#e.getDay()}get hour(){return this.#e.getHours()}get minute(){return this.#e.getMinutes()}get second(){return this.#e.getSeconds()}get millisecond(){return this.#e.getMilliseconds()}get isoWeekDay(){let e=this.weekDay;return e===0?7:e}get isoMonth(){return this.month+1}get unix(){return Math.floor(this.getTimeStamp()/1e3)}get timestamp(){return this.getTimeStamp()}get lastDateOfMonth(){return this.daysInMonth()}inspect(){return`[Chronos ${this.toLocalISOString()}]`}toJSON(){return this.toLocalISOString()}valueOf(){return this.getTimeStamp()}clone(){return new o(this.#e).#o(this.#n,this.#t,this.timeZoneName,this.timeZoneId,this.$tzTracker)}toDate(){let e=(m(this.#t)-this.getUTCOffsetMinutes())*6e4;return new Date(this.#i-e)}toString(){return this.#c(`dd mmm DD YYYY HH:mm:ss `).concat(this.#t.replace(`UTC`,`GMT`).replace(`:`,``)).concat(` (${this.timeZoneName})`)}toLocalISOString(){return this.#c(`YYYY-MM-DDTHH:mm:ss.mssZZ`)}toISOString(){return this.toDate().toISOString()}toLocaleString(e,t){return this.#e.toLocaleString(e,t)}getTimeStamp(){return this.toDate().getTime()}format(e,t=!1){return this.#c(e||`dd, mmm DD, YYYY HH:mm:ss`,t)}formatStrict(e,t=!1){return this.#c(e||`dd, mmm DD, YYYY HH:mm:ss`,t)}formatUTC(e=`dd, mmm DD, YYYY HH:mm:ss:mss`){return this.#c(e,!0)}addSeconds(e){return this.#s(this.add(e,`second`),`addSeconds`)}addMinutes(e){return this.#s(this.add(e,`minute`),`addMinutes`)}addHours(e){return this.#s(this.add(e,`hour`),`addHours`)}addDays(e){return this.#s(this.add(e,`day`),`addDays`)}addWeeks(e){return this.#s(this.add(e,`week`),`addWeeks`)}addMonths(e){return this.#s(this.add(e,`month`),`addMonths`)}addYears(e){return this.#s(this.add(e,`year`),`addYears`)}isLeapYear(e){return s(e??this.year)}isEqual(e){return this.#i===o.#u(e).#i}isEqualOrBefore(e){return this.#i<=o.#u(e).#i}isEqualOrAfter(e){return this.#i>=o.#u(e).#i}isSame(e,t,n=0){return this.startOf(t,n).#i===o.#u(e).startOf(t,n).#i}isBefore(e,t,n=0){return this.startOf(t,n).#i<o.#u(e).startOf(t,n).#i}isAfter(e,t,n=0){return this.startOf(t,n).#i>o.#u(e).startOf(t,n).#i}isSameOrBefore(e,t,n=0){return this.isSame(e,t,n)||this.isBefore(e,t,n)}isSameOrAfter(e,t,n=0){return this.isSame(e,t,n)||this.isAfter(e,t,n)}isBetween(e,t,n=`()`){let r=o.#u(e).getTimeStamp(),i=o.#u(t).getTimeStamp(),a=this.getTimeStamp();switch(n){case`[]`:return a>=r&&a<=i;case`[)`:return a>=r&&a<i;case`(]`:return a>r&&a<=i;case`()`:return a>r&&a<i;default:return!1}}isDST(){let e=this.year,t=new Date(e,0,1).getTimezoneOffset(),n=new Date(e,6,1).getTimezoneOffset();return this.#e.getTimezoneOffset()<Math.max(t,n)}isFirstDayOfMonth(){return this.isSame(this.firstDayOfMonth(),`day`)}isLastDayOfMonth(){return this.isSame(this.lastDayOfMonth(),`day`)}firstDayOfMonth(){let e=new Date(this.year,this.month,1);return this.#s(new o(e),`firstDayOfMonth`)}lastDayOfMonth(){let e=new Date(this.year,this.month+1,0);return this.#s(new o(e),`lastDayOfMonth`)}startOf(e,t=0){let n=new Date(this.#e);switch(e){case`year`:n.setMonth(0,1),n.setHours(0,0,0,0);break;case`month`:n.setDate(1),n.setHours(0,0,0,0);break;case`week`:{let e=(n.getDay()-t+7)%7;n.setDate(n.getDate()-e),n.setHours(0,0,0,0);break}case`day`:n.setHours(0,0,0,0);break;case`hour`:n.setMinutes(0,0,0);break;case`minute`:n.setSeconds(0,0);break;case`second`:n.setMilliseconds(0);break;case`millisecond`:break}return this.#s(new o(n),`startOf`)}endOf(e,t=0){let n=this.startOf(e,t).add(1,e).add(-1,`millisecond`);return this.#s(n,`endOf`)}add(e,t){let n=new Date(this.#e);switch(t){case`millisecond`:n.setMilliseconds(n.getMilliseconds()+e);break;case`second`:n.setSeconds(n.getSeconds()+e);break;case`minute`:n.setMinutes(n.getMinutes()+e);break;case`hour`:n.setHours(n.getHours()+e);break;case`day`:n.setDate(n.getDate()+e);break;case`week`:n.setDate(n.getDate()+e*7);break;case`month`:n.setMonth(n.getMonth()+e);break;case`year`:n.setFullYear(n.getFullYear()+e);break}return this.#s(new o(n),`add`)}subtract(e,t){return this.#s(this.add(-e,t),`subtract`)}get(e){switch(e){case`year`:return this.year;case`month`:return this.isoMonth;case`day`:return this.date;case`week`:return this.getWeek();case`hour`:return this.hour;case`minute`:return this.minute;case`second`:return this.second;case`millisecond`:return this.millisecond}}set(e,t){let n=new Date(this.#e);switch(e){case`year`:n.setFullYear(t);break;case`month`:n.setMonth(t-1);break;case`day`:n.setDate(t);break;case`week`:return this.setWeek(t);case`hour`:n.setHours(t);break;case`minute`:n.setMinutes(t);break;case`second`:n.setSeconds(t);break;case`millisecond`:n.setMilliseconds(t);break}return this.#s(new o(n),`set`)}diff(e,t){let n=o.#u(e),r=this.#i-n.#i;switch(t){case`millisecond`:return r;case`second`:return r/1e3;case`minute`:return r/6e4;case`hour`:return r/36e5;case`day`:return r/864e5;case`week`:return r/6048e5;case`month`:{let e=this.year-n.year,t=this.month-n.month;return e*12+t+(this.date-n.date)/this.daysInMonth()}case`year`:return this.diff(n,`month`)/12}}calendar(e){let t=e?o.#u(e):new o,n=this.startOf(`day`),r=t.startOf(`day`),i=n.diff(r,`day`),a=this.toDate().toLocaleString(`en`,{hour:`numeric`,minute:`2-digit`});return i===0?`Today at ${a}`:i===1?`Tomorrow at ${a}`:i===-1?`Yesterday at ${a}`:this.toDate().toLocaleString(`en`,{month:`long`,day:`2-digit`,year:`numeric`,weekday:`long`,hour:`numeric`,minute:`2-digit`})}fromNowShort(){let e=new o,t=this.diff(e,`second`),n=Math.abs(t),r=t>=0?`in `:``,i=t<0?` ago`:``;return n<60?`${r}${Math.floor(n)}s${i}`:n<3600?`${r}${Math.floor(n/60)}m${i}`:n<86400?`${r}${Math.floor(n/3600)}h${i}`:n<2592e3?`${r}${Math.floor(n/86400)}d${i}`:n<31536e3?`${r}${Math.floor(n/2592e3)}mo${i}`:`${r}${Math.floor(n/31536e3)}y${i}`}setWeek(e){let t=new Date(this.#e),n=t.getFullYear(),r=new Date(n,0,4),i=r.getDay()||7,a=new Date(r);return a.setDate(r.getDate()-(i-1)),a.setDate(a.getDate()+(e-1)*7),t.setFullYear(a.getFullYear()),t.setMonth(a.getMonth()),t.setDate(a.getDate()),this.#s(new o(t),`setWeek`)}getWeek(){let e=this.startOf(`week`,1).add(3,`day`),t=new o(e.year,1,4).startOf(`week`,1).add(3,`day`);return e.diff(t,`week`)+1}getWeekOfYear(e=0){let t=this.startOf(`year`).startOf(`week`,e);return this.startOf(`week`,e).diff(t,`week`)+1}getWeekYear(e=0){return this.startOf(`week`,e).add(3,`day`).year}getDayOfYear(){return this.startOf(`day`).diff(this.startOf(`year`),`day`)+1}daysInMonth(){return new Date(this.year,this.month+1,0).getDate()}toObject(){return Object.fromEntries([...this])}toArray(){return Object.values(this.toObject())}toQuarter(){let e=this.#e.getMonth();return Math.floor(e/3)+1}getUTCOffset(){let e=-this.#e.getTimezoneOffset(),t=e>=0?`+`:`-`,n=e=>String(Math.floor(Math.abs(e))).padStart(2,`0`);return`${t}${n(e/60)}:${n(e%60)}`}getTimeZoneOffset(){return this.#t.replace(`UTC`,``)}getUTCOffsetMinutes(){return-this.#e.getTimezoneOffset()}getTimeZoneOffsetMinutes(){return m(this.#t)}toUTC(){let e=this.getTimeZoneOffsetMinutes();return new o(new Date(this.#i-e*60*1e3)).#o(`toUTC`,`UTC+00:00`,`Greenwich Mean Time`,`UTC`)}toLocal(){let e=this.getTimeZoneOffsetMinutes()-this.getUTCOffsetMinutes();return new o(new Date(this.#i-e*60*1e3)).#o(`toLocal`)}day(e){return t[e??this.weekDay]}monthName(t){return e[t??this.month]}static parse(e,t){let n={YYYY:`(?<YYYY>\\d{4})`,YY:`(?<YY>\\d{2})`,MM:`(?<MM>\\d{2})`,M:`(?<M>\\d{1,2})`,DD:`(?<DD>\\d{2})`,D:`(?<D>\\d{1,2})`,HH:`(?<HH>\\d{2})`,H:`(?<H>\\d{1,2})`,mm:`(?<mm>\\d{2})`,m:`(?<m>\\d{1,2})`,ss:`(?<ss>\\d{2})`,s:`(?<s>\\d{1,2})`,mss:`(?<mss>\\d{3})`,ms:`(?<ms>\\d{1,3})`},r={YYYY:`year`,YY:`year`,MM:`month`,M:`month`,DD:`date`,D:`date`,HH:`hour`,H:`hour`,mm:`minute`,m:`minute`,ss:`second`,s:`second`,mss:`millisecond`,ms:`millisecond`},i=new RegExp(Object.keys(n).sort((e,t)=>t.length-e.length).join(`|`),`g`),a=t?.trim()?.replace(i,e=>n[e]??e)?.replace(/\s+/g,`\\s*`),s=RegExp(`^${a}\\s*$`).exec(e.trim());if(!s?.groups)throw Error(`Invalid date format!`);let c={};for(let[e,t]of Object.entries(s.groups)){let n=r[e];if(n){let r=Number(t);e===`YY`&&(r+=r<100?2e3:0),c[n]=r}}return new o(c?.year??1970,c?.month??1,c?.date??1,c?.hour??0,c?.minute??0,c?.second??0,c?.millisecond??0).#o(`parse`)}static with(e){let t=new o,{year:n,month:r,date:i,hour:a,minute:s,second:c,millisecond:l}=e??{},u=()=>t.startOf(`month`).set(`year`,n??t.year).set(`month`,r??t.isoMonth).lastDateOfMonth;return new o(n??t.year,r??t.isoMonth,i||(t.isLastDayOfMonth()&&t.date>=u()?u():t.date),a??t.hour,s??t.minute,c??t.second,l??t.millisecond).#o(`with`)}static today(e){let{format:t=`dd, mmm DD, YYYY HH:mm:ss`,useUTC:n=!1}=e||{};return new o().#c(t,n)}static yesterday(){let e=new Date;return new o(e.setDate(e.getDate()-1)).#o(`yesterday`)}static tomorrow(){let e=new Date;return new o(e.setDate(e.getDate()+1)).#o(`tomorrow`)}static now(){return Date.now()}static utc(e){let t=new o(e),n=t.getTimeZoneOffsetMinutes();return new o(new Date(t.#i-n*60*1e3)).#o(`utc`,`UTC+00:00`,`Greenwich Mean Time`,`UTC`)}static formatTimePart(e,t){return new o(`${new o().#c(`YYYY-MM-DD`)}T${f(e)}`).#c(t||`hh:mm:ss a`)}static getDatesForDay(e,n){let i=new o,a=i.addWeeks(4),{format:s=`local`,roundDate:c=!1}=n??{};if(n){if(`from`in n||`to`in n)n?.from&&(i=o.#u(n?.from)),n?.to&&(a=o.#u(n?.to));else if(`span`in n||`unit`in n){let{span:e=4,unit:t=`week`}=n??{};a=i.add(e,t)}}c&&(i=i.startOf(`day`),a=a.startOf(`day`));let l=[],u=(i.isBefore(a,`day`)?1:-1)*r,d=Math.abs(a.diff(i,`day`)),f=i.#i,p=0;for(;new Date(f+p*u).getDay()!==t.indexOf(e);)p++;for(let e=p;e<=d;e+=7){let t=new o(f+e*u).#o(`clone`,i.#t,i.timeZoneName,i.timeZoneId,i.$tzTracker);l.push(s===`local`?t.toLocalISOString():t.toISOString())}return l}static min(...e){let t=o.#u(e[0]);for(let n of e){let e=o.#u(n);e.getTimeStamp()<t.getTimeStamp()&&(t=e)}return t.#s(t,t.#n===`root`?`min`:t.#n)}static max(...e){let t=o.#u(e[0]);for(let n of e){let e=o.#u(n);e.getTimeStamp()>t.getTimeStamp()&&(t=e)}return t.#s(t,t.#n===`root`?`max`:t.#n)}static isLeapYear(e){let t;return t=a(e)?e>0&&e<=9999?e:new Date(e).getFullYear():o.#u(e).year,s(t)}static isValidDate(e){return e instanceof Date}static isDateString(e){return i(e)&&!isNaN(Date.parse(e))}static isValidChronos(e){return e instanceof o}static isReconstructable(e){return c(e)}static reconstruct(e){if(!c(e))throw TypeError(`Invalid input for reconstruction!`);let{native:t,origin:n,utcOffset:r,timeZoneName:i,timeZoneId:a,$tzTracker:s}=e,l=m(r),u=new o(t),d=u.getTimeZoneOffsetMinutes()-l;return(u.utcOffset===r?u:u.add(-d,`minute`)).#o(n,r,i,a,s)}static use(e){o.#r.has(e)||(o.#r.add(e),e(o))}static register(e){o.use(e)}static#u(e){return e instanceof o?e:new o(e)}};export{v as Chronos,n as INTERNALS,_ as chronos};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return Array.isArray(e)}function t(e){return Array.isArray(e)&&e?.length>0}function n(t){return typeof t==`object`&&!!t&&!e(t)}function r(e){return n(e)&&Object.keys(e)?.length>0}function i(e,t){return n(e)&&t?.every(t=>t in e)}function a(e){return typeof e==`function`}export{t as a,i,r as n,n as r,a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return Array.isArray(e)}function t(e){return Array.isArray(e)&&e?.length>0}function n(t){return typeof t==`object`&&!!t&&!e(t)}function r(e){return n(e)&&Object.keys(e)?.length>0}function i(e,t){return n(e)&&t?.every(t=>t in e)}function a(e){return typeof e==`function`}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../basic-CKxaRSHQ.cjs`),t=require(`../primitives-Db2FUp4e.cjs`),n=require(`../utilities-D2-p26DX.cjs`),r=require(`../helpers-DGzYnP81.cjs`);function i(e,r=!0){let i=Object.keys(n.i),a=e=>e.replace(/\d/g,e=>i[Number(e)]);if(t.r(e))return a(String(e));if(t.n(e)){let t=a(e);return r||n.a(e)?t:t.split(``).filter(e=>i.includes(e)).join(``)}return``}const a=t=>{let{internalDate:n}=t[e.s],a=new Map;function o(e,t){return r.t(e,t??a.get(`config`)?.variant)}t.prototype.configureBanglaCalendar=function(e){a.set(`config`,e)},t.prototype.getBanglaYear=function(e=`bn`){let t=r.o(n(this));return e===`en`?t:i(t)},t.prototype.getBanglaMonth=function(e){let{locale:t=`bn`,variant:r}=e??{},a=o(n(this),r).monthIdx+1;return t===`en`?a:i(a)},t.prototype.getBanglaDay=function(e){let{locale:t=`bn`,variant:r}=e??{},a=o(n(this),r).days+1;return t===`en`?a:i(a)},t.prototype.getBanglaDayName=function(t=`bn`){let n=e.t[this.weekDay];return t===`en`?n.en:n.bn},t.prototype.getBanglaMonthName=function(t){let{locale:r=`bn`,variant:i}=t??{},{monthIdx:a}=o(n(this),i),s=e.n[a];return r===`en`?s.en:s.bn},t.prototype.getBanglaSeasonName=function(e){let{locale:t,variant:i}=e??{},{monthIdx:a}=o(n(this),i);return r.a(a,t)},t.prototype.toBangla=function(e){return{year:this.getBanglaYear(e?.locale),month:this.getBanglaMonth(e),date:this.getBanglaDay(e),monthName:this.getBanglaMonthName(e),dayName:this.getBanglaDayName(e?.locale),seasonName:this.getBanglaSeasonName(e),isLeapYear:r.l(r.o(n(this)),this.year,e?.variant)}},t.prototype.formatBangla=function(t,a){let{hour:s,minute:c,second:l,millisecond:u}=this,d=e.t[this.weekDay],{monthIdx:f}=o(n(this),a?.variant),p=e.n[f],m=this.getBanglaMonth(),h=r.d(this.getBanglaYear(),4),g=this.getBanglaDay(),_=this.getBanglaSeasonName(),v=i(this.getTimeZoneOffset()),y={YYYY:h,YY:h.slice(-2),yyyy:h,yy:h.slice(-2),M:m,MM:r.d(m),mmm:p.short,mmmm:p.bn,d:d.short,dd:d.bn.replace(`বার`,``),ddd:d.bn,D:g,DD:r.d(g),Do:g,H:i(s),HH:r.d(i(s)),h:i(s%12||12),hh:r.d(i(s%12||12)),m:i(c),mm:r.d(i(c)),s:i(l),ss:r.d(i(l)),ms:i(u),mss:r.d(i(u),3),a:s<12?`পূর্বাহ্ণ`:`অপরাহ্ণ`,A:s<12?`পূর্বাহ্ণ`:`অপরাহ্ণ`,Z:v,ZZ:v,S:_,SS:_+`কাল`};return r.i(t||`ddd, DD mmmm (SS), YYYY বঙ্গাব্দ - hh:mm:ss (A)`,y)}};exports.banglaPlugin=a;
|