neramjs 0.0.0-stage → 0.1.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/CHANGELOG.md +39 -0
- package/LICENSE +21 -0
- package/README.md +121 -2
- package/dist/calendar.d.ts +25 -0
- package/dist/calendar.js +59 -0
- package/dist/cjs/neram.cjs +3136 -0
- package/dist/duration.d.ts +69 -0
- package/dist/duration.js +271 -0
- package/dist/format.d.ts +13 -0
- package/dist/format.js +115 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2 -0
- package/dist/intl.d.ts +15 -0
- package/dist/intl.js +72 -0
- package/dist/locale.d.ts +53 -0
- package/dist/locale.js +107 -0
- package/dist/neram.d.ts +287 -0
- package/dist/neram.global.js +2 -0
- package/dist/neram.js +910 -0
- package/dist/neram.min.js +2 -0
- package/dist/neram.recur.global.js +3 -0
- package/dist/parse.d.ts +14 -0
- package/dist/parse.js +278 -0
- package/dist/recur/cron.d.ts +41 -0
- package/dist/recur/cron.js +275 -0
- package/dist/recur/index.cjs +2 -0
- package/dist/recur/index.d.cts +24 -0
- package/dist/recur/index.d.ts +6 -0
- package/dist/recur/index.js +3 -0
- package/dist/recur/rrule.d.ts +108 -0
- package/dist/recur/rrule.js +731 -0
- package/dist/recur/schedule.d.ts +85 -0
- package/dist/recur/schedule.js +169 -0
- package/dist/recur.min.js +3 -0
- package/dist/relative.d.ts +17 -0
- package/dist/relative.js +26 -0
- package/dist/units.d.ts +13 -0
- package/dist/units.js +44 -0
- package/dist/weekdata.d.ts +22 -0
- package/dist/weekdata.js +58 -0
- package/dist/zone.d.ts +48 -0
- package/dist/zone.js +247 -0
- package/package.json +89 -4
package/dist/locale.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names come from Intl, so every BCP 47 locale works without shipping locale files.
|
|
3
|
+
* Week rules come from a small built-in CLDR table (see weekdata.ts) so they never vary by runtime.
|
|
4
|
+
*/
|
|
5
|
+
import { clean } from './intl.js';
|
|
6
|
+
import { weekRules } from './weekdata.js';
|
|
7
|
+
const cache = new Map();
|
|
8
|
+
export function canonicalLocale(locale) {
|
|
9
|
+
try {
|
|
10
|
+
return Intl.getCanonicalLocales(locale)[0] ?? 'en';
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
throw new RangeError(`neram: invalid locale "${locale}"`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function weekInfo(locale) {
|
|
17
|
+
// Shipped CLDR data, not Intl.Locale#getWeekInfo, so every runtime agrees.
|
|
18
|
+
return weekRules(locale);
|
|
19
|
+
}
|
|
20
|
+
export function localeData(locale) {
|
|
21
|
+
let data = cache.get(locale);
|
|
22
|
+
if (data)
|
|
23
|
+
return data;
|
|
24
|
+
const base = (opts) => new Intl.DateTimeFormat(locale, { ...opts, timeZone: 'UTC' });
|
|
25
|
+
const fmt = (opts) => {
|
|
26
|
+
const f = base(opts);
|
|
27
|
+
return {
|
|
28
|
+
format: (t) => clean(f.format(t)),
|
|
29
|
+
formatToParts: (t) => f.formatToParts(t).map((p) => ({ ...p, value: clean(p.value) })),
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const mLong = fmt({ month: 'long' });
|
|
33
|
+
const mShort = fmt({ month: 'short' });
|
|
34
|
+
// Standalone vs. format month names differ in some languages; the "day + month" form
|
|
35
|
+
// is what appears in formatted dates, so take it from there when it differs.
|
|
36
|
+
const mLongInDate = fmt({ month: 'long', day: 'numeric' });
|
|
37
|
+
const months = [];
|
|
38
|
+
const monthsShort = [];
|
|
39
|
+
for (let i = 0; i < 12; i++) {
|
|
40
|
+
const t = Date.UTC(2021, i, 15);
|
|
41
|
+
const inDate = mLongInDate.formatToParts(t).find((p) => p.type === 'month')?.value;
|
|
42
|
+
months.push(inDate ?? mLong.format(t));
|
|
43
|
+
monthsShort.push(mShort.format(t).replace(/\.$/, ''));
|
|
44
|
+
}
|
|
45
|
+
const wLong = fmt({ weekday: 'long' });
|
|
46
|
+
const wShort = fmt({ weekday: 'short' });
|
|
47
|
+
const wNarrow = fmt({ weekday: 'narrow' });
|
|
48
|
+
const isEnglish = locale.toLowerCase().startsWith('en');
|
|
49
|
+
const weekdays = [];
|
|
50
|
+
const weekdaysShort = [];
|
|
51
|
+
const weekdaysMin = [];
|
|
52
|
+
for (let i = 0; i < 7; i++) {
|
|
53
|
+
const t = Date.UTC(2021, 0, 3 + i); // 2021-01-03 was a Sunday
|
|
54
|
+
weekdays.push(wLong.format(t));
|
|
55
|
+
const short = wShort.format(t).replace(/\.$/, '');
|
|
56
|
+
weekdaysShort.push(short);
|
|
57
|
+
weekdaysMin.push(isEnglish ? short.slice(0, 2) : wNarrow.format(t));
|
|
58
|
+
}
|
|
59
|
+
const hour12 = fmt({ hour: 'numeric', hour12: true });
|
|
60
|
+
const dp = (t) => hour12.formatToParts(t).find((p) => p.type === 'dayPeriod')?.value;
|
|
61
|
+
const meridiem = [
|
|
62
|
+
dp(Date.UTC(2021, 0, 1, 9)) ?? 'AM',
|
|
63
|
+
dp(Date.UTC(2021, 0, 1, 15)) ?? 'PM',
|
|
64
|
+
];
|
|
65
|
+
data = { months, monthsShort, weekdays, weekdaysShort, weekdaysMin, meridiem, week: weekInfo(locale) };
|
|
66
|
+
cache.set(locale, data);
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
69
|
+
const ordinalRules = new Map();
|
|
70
|
+
const EN_SUFFIX = { one: 'st', two: 'nd', few: 'rd', other: 'th' };
|
|
71
|
+
export function ordinal(n, locale) {
|
|
72
|
+
if (!locale.toLowerCase().startsWith('en'))
|
|
73
|
+
return `${n}.`;
|
|
74
|
+
let pr = ordinalRules.get(locale);
|
|
75
|
+
if (!pr) {
|
|
76
|
+
pr = new Intl.PluralRules(locale, { type: 'ordinal' });
|
|
77
|
+
ordinalRules.set(locale, pr);
|
|
78
|
+
}
|
|
79
|
+
return `${n}${EN_SUFFIX[pr.select(n)] ?? 'th'}`;
|
|
80
|
+
}
|
|
81
|
+
const publicCache = new Map();
|
|
82
|
+
export function publicLocaleData(locale) {
|
|
83
|
+
let out = publicCache.get(locale);
|
|
84
|
+
if (out)
|
|
85
|
+
return out;
|
|
86
|
+
const d = localeData(locale);
|
|
87
|
+
const pick = (list, at) => (x) => (x === undefined ? list.slice() : list[at(x)]);
|
|
88
|
+
const byMonth = (x) => x.month();
|
|
89
|
+
const byDay = (x) => x.day();
|
|
90
|
+
out = Object.freeze({
|
|
91
|
+
name: locale,
|
|
92
|
+
firstDayOfWeek: () => d.week.firstDay,
|
|
93
|
+
months: pick(d.months, byMonth),
|
|
94
|
+
monthsShort: pick(d.monthsShort, byMonth),
|
|
95
|
+
weekdays: pick(d.weekdays, byDay),
|
|
96
|
+
weekdaysShort: pick(d.weekdaysShort, byDay),
|
|
97
|
+
weekdaysMin: pick(d.weekdaysMin, byDay),
|
|
98
|
+
meridiem: (hour, _minute, isLowercase) => {
|
|
99
|
+
const m = d.meridiem[hour < 12 ? 0 : 1];
|
|
100
|
+
return isLowercase ? m.toLocaleLowerCase(locale) : m;
|
|
101
|
+
},
|
|
102
|
+
ordinal: (n) => ordinal(n, locale),
|
|
103
|
+
week: () => ({ ...d.week, weekend: d.week.weekend.slice() }),
|
|
104
|
+
});
|
|
105
|
+
publicCache.set(locale, out);
|
|
106
|
+
return out;
|
|
107
|
+
}
|
package/dist/neram.d.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { Duration, type DurationInput, duration, isDuration } from './duration.ts';
|
|
2
|
+
import { type NeramLocaleData } from './locale.ts';
|
|
3
|
+
import { type RelativeTimeOptions } from './relative.ts';
|
|
4
|
+
import { type UnitInput } from './units.ts';
|
|
5
|
+
/** A date given as fields. `month` is 0-11, as everywhere else in the API. */
|
|
6
|
+
export interface DateObject {
|
|
7
|
+
year?: number;
|
|
8
|
+
month?: number;
|
|
9
|
+
date?: number;
|
|
10
|
+
day?: number;
|
|
11
|
+
hour?: number;
|
|
12
|
+
minute?: number;
|
|
13
|
+
second?: number;
|
|
14
|
+
millisecond?: number;
|
|
15
|
+
}
|
|
16
|
+
/** Anything with epochMilliseconds: Temporal.Instant, Temporal.ZonedDateTime. */
|
|
17
|
+
export interface EpochLike {
|
|
18
|
+
epochMilliseconds: number;
|
|
19
|
+
timeZoneId?: string;
|
|
20
|
+
}
|
|
21
|
+
export type NeramInput = Neram | Date | number | string | DateObject | EpochLike | number[] | null | undefined;
|
|
22
|
+
export interface ParseOptions {
|
|
23
|
+
/** Custom format(s) to parse with, tried in order. */
|
|
24
|
+
format?: string | string[];
|
|
25
|
+
/** Reject input that does not round-trip through the format exactly. */
|
|
26
|
+
strict?: boolean;
|
|
27
|
+
/** BCP 47 locale for names and formatting, e.g. "ta", "de-CH". */
|
|
28
|
+
locale?: string;
|
|
29
|
+
/** Time zone: "local", "UTC", "+05:30" or an IANA name. */
|
|
30
|
+
zone?: string;
|
|
31
|
+
/** Shorthand for zone: "UTC". */
|
|
32
|
+
utc?: boolean;
|
|
33
|
+
/** Override the locale's first day of the week (0 = Sunday … 6 = Saturday). */
|
|
34
|
+
weekStart?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface NeramConfig {
|
|
37
|
+
locale: string;
|
|
38
|
+
zone: string;
|
|
39
|
+
weekStart?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Replace the Unicode spaces Intl puts in localized text (U+202F before "PM", U+00A0) with
|
|
42
|
+
* plain spaces, so server and browser strings compare equal. Default true.
|
|
43
|
+
*/
|
|
44
|
+
normalizeSpaces: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** What this runtime is using, for comparing a server with a browser. */
|
|
47
|
+
export interface NeramEnvironment {
|
|
48
|
+
/** The runtime's own zone */
|
|
49
|
+
zone: string;
|
|
50
|
+
/** neram's default zone (neram.config) */
|
|
51
|
+
defaultZone: string;
|
|
52
|
+
/** neram's default locale */
|
|
53
|
+
locale: string;
|
|
54
|
+
/** The runtime's default locale */
|
|
55
|
+
runtimeLocale: string;
|
|
56
|
+
/** ICU / CLDR / tz database versions. Node exposes these; browsers do not (undefined). */
|
|
57
|
+
icu?: string;
|
|
58
|
+
cldr?: string;
|
|
59
|
+
tzdata?: string;
|
|
60
|
+
/** Intl APIs neram uses where present, with fallbacks where not. */
|
|
61
|
+
features: {
|
|
62
|
+
relativeTimeFormat: boolean;
|
|
63
|
+
listFormat: boolean;
|
|
64
|
+
durationFormat: boolean;
|
|
65
|
+
supportedValuesOf: boolean;
|
|
66
|
+
unitFormat: boolean;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export interface CalendarOptions {
|
|
70
|
+
/** Shown for dates more than a week away. Default "L". */
|
|
71
|
+
sameElse?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface BusinessDayOptions {
|
|
74
|
+
/** Dates that are not business days. Compared by calendar day in this instance's zone. */
|
|
75
|
+
holidays?: NeramInput[];
|
|
76
|
+
/** Weekday numbers (0-6) to treat as weekend. Default: the locale's weekend. */
|
|
77
|
+
weekend?: number[];
|
|
78
|
+
}
|
|
79
|
+
type Inclusivity = '()' | '[]' | '[)' | '(]';
|
|
80
|
+
export declare class Neram {
|
|
81
|
+
#private;
|
|
82
|
+
/** @internal Use `neram()` instead. */
|
|
83
|
+
constructor(ms: number, zone: string, locale: string, weekStart?: number);
|
|
84
|
+
isValid(): boolean;
|
|
85
|
+
clone(): Neram;
|
|
86
|
+
get(unit: UnitInput): number;
|
|
87
|
+
set(unit: UnitInput, value: number): Neram;
|
|
88
|
+
set(values: DateObject): Neram;
|
|
89
|
+
year(): number;
|
|
90
|
+
year(v: number): Neram;
|
|
91
|
+
/** 0-11 */
|
|
92
|
+
month(): number;
|
|
93
|
+
month(v: number): Neram;
|
|
94
|
+
/** Day of the month, 1-31. */
|
|
95
|
+
date(): number;
|
|
96
|
+
date(v: number): Neram;
|
|
97
|
+
/** Day of the week, 0 (Sunday) - 6 (Saturday). */
|
|
98
|
+
day(): number;
|
|
99
|
+
day(v: number): Neram;
|
|
100
|
+
hour(): number;
|
|
101
|
+
hour(v: number): Neram;
|
|
102
|
+
minute(): number;
|
|
103
|
+
minute(v: number): Neram;
|
|
104
|
+
second(): number;
|
|
105
|
+
second(v: number): Neram;
|
|
106
|
+
millisecond(): number;
|
|
107
|
+
millisecond(v: number): Neram;
|
|
108
|
+
/** 1-4 */
|
|
109
|
+
quarter(): number;
|
|
110
|
+
quarter(v: number): Neram;
|
|
111
|
+
/** 1-366 */
|
|
112
|
+
dayOfYear(): number;
|
|
113
|
+
dayOfYear(v: number): Neram;
|
|
114
|
+
/** Day of the week with Monday = 1 … Sunday = 7. */
|
|
115
|
+
isoWeekday(): number;
|
|
116
|
+
isoWeekday(v: number): Neram;
|
|
117
|
+
/** Locale-aware weekday: 0 is the locale's first day of the week. */
|
|
118
|
+
weekday(): number;
|
|
119
|
+
weekday(v: number): Neram;
|
|
120
|
+
/** Locale week of the year (uses the locale's first day and minimal-days rule). */
|
|
121
|
+
week(): number;
|
|
122
|
+
weekYear(): number;
|
|
123
|
+
/** ISO 8601 week number, 1-53. */
|
|
124
|
+
isoWeek(): number;
|
|
125
|
+
isoWeekYear(): number;
|
|
126
|
+
isoWeeksInYear(): number;
|
|
127
|
+
daysInMonth(): number;
|
|
128
|
+
isLeapYear(): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Add time. Calendar units (day and up) keep the wall-clock time across DST changes;
|
|
131
|
+
* exact units (hour and down) add elapsed time.
|
|
132
|
+
* neram().add(3, 'day')
|
|
133
|
+
* neram().add({ months: 1, hours: 2 })
|
|
134
|
+
* neram().add('P1DT12H')
|
|
135
|
+
*/
|
|
136
|
+
add(amount: number, unit?: UnitInput): Neram;
|
|
137
|
+
add(amount: DurationInput): Neram;
|
|
138
|
+
subtract(amount: number, unit?: UnitInput): Neram;
|
|
139
|
+
subtract(amount: DurationInput): Neram;
|
|
140
|
+
startOf(unit: UnitInput): Neram;
|
|
141
|
+
endOf(unit: UnitInput): Neram;
|
|
142
|
+
/** Round to the nearest unit boundary: neram('10:40').round('hour') → 11:00. */
|
|
143
|
+
round(unit: UnitInput): Neram;
|
|
144
|
+
/** Keep the date inside [min, max]. */
|
|
145
|
+
clamp(min: NeramInput, max: NeramInput): Neram;
|
|
146
|
+
/**
|
|
147
|
+
* The same instant in another zone, or (keepLocalTime) the same wall time in another zone.
|
|
148
|
+
* neram('2026-12-04T09:00Z').tz('Asia/Kolkata').format('HH:mm') → "14:30"
|
|
149
|
+
*/
|
|
150
|
+
tz(zone: string, keepLocalTime?: boolean): Neram;
|
|
151
|
+
utc(keepLocalTime?: boolean): Neram;
|
|
152
|
+
local(keepLocalTime?: boolean): Neram;
|
|
153
|
+
/** The IANA name (or "UTC" / "+05:30") of this instance's zone. */
|
|
154
|
+
timezone(): string;
|
|
155
|
+
isUTC(): boolean;
|
|
156
|
+
isLocal(): boolean;
|
|
157
|
+
/** Offset from UTC in minutes; with an argument, switch to that fixed offset. */
|
|
158
|
+
utcOffset(): number;
|
|
159
|
+
utcOffset(offset: number | string, keepLocalTime?: boolean): Neram;
|
|
160
|
+
/** True when daylight-saving time is in effect in this instance's zone. */
|
|
161
|
+
isDST(): boolean;
|
|
162
|
+
/** Month and weekday names and week rules for this value's locale. Day.js-compatible. */
|
|
163
|
+
localeData(): NeramLocaleData;
|
|
164
|
+
locale(): string;
|
|
165
|
+
locale(locale: string): Neram;
|
|
166
|
+
/** Override the locale's first day of the week (0 = Sunday … 6 = Saturday). */
|
|
167
|
+
weekStart(): number;
|
|
168
|
+
weekStart(day: number): Neram;
|
|
169
|
+
/**
|
|
170
|
+
* Format with Day.js tokens, plus:
|
|
171
|
+
* W/WW ISO week · GGGG ISO week-year · E ISO weekday · Qo ordinal quarter
|
|
172
|
+
* z/zzz zone name · S…SSSSSSSSS fraction · L LL LLL LLLL LT LTS (via Intl)
|
|
173
|
+
*/
|
|
174
|
+
format(fmt?: string): string;
|
|
175
|
+
/** Format with Intl options: neram().toLocaleString({ dateStyle: 'full' }, 'ta') */
|
|
176
|
+
toLocaleString(opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
177
|
+
/** "in 3 hours", "yesterday", "2 months ago" — relative to another date. */
|
|
178
|
+
from(other: NeramInput, opts?: RelativeTimeOptions): string;
|
|
179
|
+
fromNow(opts?: RelativeTimeOptions): string;
|
|
180
|
+
to(other: NeramInput, opts?: RelativeTimeOptions): string;
|
|
181
|
+
toNow(opts?: RelativeTimeOptions): string;
|
|
182
|
+
/** "Today at 3:00 PM", "Tomorrow at 9:00 AM", "Last Friday at …", or a date. */
|
|
183
|
+
calendar(reference?: NeramInput, opts?: CalendarOptions): string;
|
|
184
|
+
/**
|
|
185
|
+
* Difference in a unit, truncated toward zero unless `float`.
|
|
186
|
+
* Months and years are calendar-aware; days and weeks count local calendar days (DST-safe).
|
|
187
|
+
*/
|
|
188
|
+
diff(other: NeramInput, unit?: UnitInput, float?: boolean): number;
|
|
189
|
+
/** Whole Duration between two dates, calendar-correct: 1 year 2 months 3 days … */
|
|
190
|
+
durationTo(other: NeramInput): Duration;
|
|
191
|
+
isBefore(other: NeramInput, unit?: UnitInput): boolean;
|
|
192
|
+
isAfter(other: NeramInput, unit?: UnitInput): boolean;
|
|
193
|
+
isSame(other: NeramInput, unit?: UnitInput): boolean;
|
|
194
|
+
isSameOrBefore(other: NeramInput, unit?: UnitInput): boolean;
|
|
195
|
+
isSameOrAfter(other: NeramInput, unit?: UnitInput): boolean;
|
|
196
|
+
isBetween(a: NeramInput, b: NeramInput, unit?: UnitInput, inclusivity?: Inclusivity): boolean;
|
|
197
|
+
isToday(): boolean;
|
|
198
|
+
isTomorrow(): boolean;
|
|
199
|
+
isYesterday(): boolean;
|
|
200
|
+
isPast(): boolean;
|
|
201
|
+
isFuture(): boolean;
|
|
202
|
+
isWeekend(weekend?: number[]): boolean;
|
|
203
|
+
isBusinessDay(opts?: BusinessDayOptions): boolean;
|
|
204
|
+
/** Step over weekends and holidays. Negative n goes backwards. */
|
|
205
|
+
addBusinessDays(n: number, opts?: BusinessDayOptions): Neram;
|
|
206
|
+
subtractBusinessDays(n: number, opts?: BusinessDayOptions): Neram;
|
|
207
|
+
/** Business days from this date (exclusive) to `other` (inclusive); negative if earlier. */
|
|
208
|
+
businessDaysUntil(other: NeramInput, opts?: BusinessDayOptions): number;
|
|
209
|
+
valueOf(): number;
|
|
210
|
+
/** Seconds since the epoch. */
|
|
211
|
+
unix(): number;
|
|
212
|
+
toDate(): Date;
|
|
213
|
+
toISOString(): string;
|
|
214
|
+
/**
|
|
215
|
+
* RFC 9557 / Temporal string with the zone kept:
|
|
216
|
+
* "2026-12-04T14:30:00+05:30[Asia/Kolkata]"
|
|
217
|
+
*/
|
|
218
|
+
toZonedISOString(): string;
|
|
219
|
+
/** A Temporal.ZonedDateTime, where the runtime has Temporal. */
|
|
220
|
+
toTemporal(): unknown;
|
|
221
|
+
toJSON(): string | null;
|
|
222
|
+
toString(): string;
|
|
223
|
+
toObject(): Required<Omit<DateObject, 'day'>>;
|
|
224
|
+
toArray(): number[];
|
|
225
|
+
[Symbol.toPrimitive](hint: string): string | number;
|
|
226
|
+
get [Symbol.toStringTag](): string;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Create a date.
|
|
230
|
+
* neram() now
|
|
231
|
+
* neram('2026-12-04') local midnight
|
|
232
|
+
* neram('2026-12-04T10:00+05:30') exact instant
|
|
233
|
+
* neram('2026-12-04T10:00[Asia/Tokyo]') RFC 9557 — wall time in that zone
|
|
234
|
+
* neram('04/12/2026', 'DD/MM/YYYY') custom format
|
|
235
|
+
* neram('04/12/2026', 'DD/MM/YYYY', true) strict
|
|
236
|
+
* neram({ year: 2026, month: 11, date: 4 }) fields
|
|
237
|
+
* neram(Temporal.Now.instant()) Temporal interop
|
|
238
|
+
*/
|
|
239
|
+
declare function create(input?: NeramInput, formatOrOpts?: string | string[] | ParseOptions, localeOrStrict?: string | boolean, strict?: boolean): Neram;
|
|
240
|
+
export type Plugin<O = unknown> = (option: O, cls: typeof Neram, factory: typeof neram) => void;
|
|
241
|
+
export declare const neram: typeof create & {
|
|
242
|
+
/** Parse in UTC: neram.utc('2026-12-04 10:00') */
|
|
243
|
+
utc(input?: NeramInput, format?: string | string[], strict?: boolean): Neram;
|
|
244
|
+
/** Parse a wall time in a zone, or convert an instant to it: neram.tz('2026-03-08 02:30', 'America/New_York') */
|
|
245
|
+
tz(input: NeramInput, zone: string, format?: string | string[]): Neram;
|
|
246
|
+
/** From seconds since the epoch. */
|
|
247
|
+
unix(seconds: number): Neram;
|
|
248
|
+
now(): Neram;
|
|
249
|
+
duration: typeof duration;
|
|
250
|
+
isDuration: typeof isDuration;
|
|
251
|
+
Duration: typeof Duration;
|
|
252
|
+
Neram: typeof Neram;
|
|
253
|
+
isNeram(x: unknown): x is Neram;
|
|
254
|
+
min(...dates: (NeramInput | NeramInput[])[]): Neram | null;
|
|
255
|
+
max(...dates: (NeramInput | NeramInput[])[]): Neram | null;
|
|
256
|
+
/** Sorted copy, earliest first. */
|
|
257
|
+
sort(dates: NeramInput[]): Neram[];
|
|
258
|
+
/**
|
|
259
|
+
* Every date from start to end (inclusive) in steps:
|
|
260
|
+
* neram.range('2026-12-01', '2026-12-07') — 7 days
|
|
261
|
+
* neram.range(start, end, { unit: 'week', step: 2 })
|
|
262
|
+
*/
|
|
263
|
+
range(start: NeramInput, end: NeramInput, opts?: {
|
|
264
|
+
unit?: UnitInput;
|
|
265
|
+
step?: number;
|
|
266
|
+
exclusive?: boolean;
|
|
267
|
+
limit?: number;
|
|
268
|
+
}): Neram[];
|
|
269
|
+
/** Get or set the default locale for new instances. */
|
|
270
|
+
locale(locale?: string): string;
|
|
271
|
+
/** Month and weekday names and week rules for a locale (the default locale if omitted). Day.js-compatible. */
|
|
272
|
+
localeData(locale?: string): NeramLocaleData;
|
|
273
|
+
/**
|
|
274
|
+
* Versions and features of this runtime's date data. Log it on the server and in the browser:
|
|
275
|
+
* if icu/cldr/tzdata or the zone differ, localized text or future DST changes may differ too.
|
|
276
|
+
*/
|
|
277
|
+
environment(): NeramEnvironment;
|
|
278
|
+
/** The runtime's IANA time zone. */
|
|
279
|
+
guess(): string;
|
|
280
|
+
/** Every IANA zone the runtime knows (where Intl.supportedValuesOf exists). */
|
|
281
|
+
zones(): string[];
|
|
282
|
+
/** Set defaults: neram.config({ locale: 'ta', zone: 'Asia/Kolkata', weekStart: 1 }) */
|
|
283
|
+
config(next?: Partial<NeramConfig>): Readonly<NeramConfig>;
|
|
284
|
+
/** Day.js-style plugins: (option, NeramClass, neram) => void. Installed once. */
|
|
285
|
+
extend<O>(plugin: Plugin<O>, option?: O): typeof neram;
|
|
286
|
+
};
|
|
287
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! neramjs v0.1.0 | MIT | github.com/varksh05/neramjs */
|
|
2
|
+
"use strict";(()=>{function _(t,e,n,r=0,s=0,i=0,a=0){if(t>=100)return Date.UTC(t,e,n,r,s,i,a);let o=new Date(0);return o.setUTCFullYear(t,e,n),o.setUTCHours(r,s,i,a),o.getTime()}function ye(t){return _(t.y,t.M,t.D,t.h,t.m,t.s,t.ms)}var Te=/^([+-])(\d{2}):?(\d{2})$/;function B(t){if(t==="Z"||t==="z")return 0;let e=Te.exec(t)??/^([+-])(\d{2})$/.exec(t);if(!e)return;let n=Number(e[2]),r=Number(e[3]??0);if(n>23||r>59)return;let s=n*60+r;return e[1]==="-"?-s:s}function P(t,e=":"){let n=t<0?"-":"+",r=Math.abs(t);return`${n}${String(Math.floor(r/60)).padStart(2,"0")}${e}${String(r%60).padStart(2,"0")}`}function ve(t){return Te.test(t)}var rt={"Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Katmandu":"Asia/Kathmandu","Asia/Rangoon":"Asia/Yangon","Europe/Kiev":"Europe/Kyiv","Atlantic/Faeroe":"Atlantic/Faroe","America/Godthab":"America/Nuuk","Pacific/Enderbury":"Pacific/Kanton","Pacific/Truk":"Pacific/Chuuk","Pacific/Ponape":"Pacific/Pohnpei","Africa/Asmera":"Africa/Asmara","America/Buenos_Aires":"America/Argentina/Buenos_Aires","America/Catamarca":"America/Argentina/Catamarca","America/Cordoba":"America/Argentina/Cordoba","America/Jujuy":"America/Argentina/Jujuy","America/Mendoza":"America/Argentina/Mendoza","America/Indianapolis":"America/Indiana/Indianapolis","America/Louisville":"America/Kentucky/Louisville"};function st(t){try{return new Intl.DateTimeFormat("en-US",{timeZone:t}),!0}catch{return!1}}function Ue(t){let e=rt[t];return e&&st(e)?e:t}var ke=new Map;function z(t){if(t==null||t==="local")return"local";if(typeof t!="string"||t.trim()==="")throw new RangeError(`neram: unknown time zone ${JSON.stringify(t)}`);let e=ke.get(t);if(e)return e;let n,r=t.toUpperCase();if(r==="UTC"||r==="Z"||r==="GMT"||r==="ETC/UTC"||r==="ETC/GMT")n="UTC";else{let s=B(t);if(s!==void 0)n=s===0?"UTC":P(s);else try{let i=new Intl.DateTimeFormat("en-US",{timeZone:t}).resolvedOptions().timeZone;n=Ue(i.toLowerCase()===t.toLowerCase()?i:t)}catch{throw new RangeError(`neram: unknown time zone "${t}"`)}}return ke.set(t,n),n}var Se=new Map;function it(t){let e=Se.get(t);return e||(e=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),Se.set(t,e)),e}function ae(t,e){let n=it(e).formatToParts(new Date(t)),r=0,s=0,i=0,a=0,o=0,u=0,m=!1;for(let c of n)switch(c.type){case"year":r=Number(c.value);break;case"month":s=Number(c.value)-1;break;case"day":i=Number(c.value);break;case"hour":a=Number(c.value)%24;break;case"minute":o=Number(c.value);break;case"second":u=Number(c.value);break;case"era":m=/^b/i.test(c.value);break}m&&(r=1-r);let l=t-(t%1e3+1e3)%1e3;return Math.round((_(r,s,i,a,o,u)-l)/6e4)}var oe=864e5,at=5e4,Ie=-1e9,Oe=new Map;function ot(t,e){let n=Oe.get(e);n||(n=new Map,Oe.set(e,n));let r=Math.floor(t/oe),s=n.get(r);if(s!==void 0)return s===Ie?ae(t,e):s;let i=ae(r*oe,e),a=ae(r*oe+oe-1e3,e);return n.size>=at&&n.clear(),n.set(r,i===a?i:Ie),i===a?i:ae(t,e)}var ge=new Map;function C(t,e){if(e==="UTC")return 0;if(e==="local")return-new Date(t).getTimezoneOffset()||0;let n=ge.get(e);return n===void 0&&!ge.has(e)&&(n=B(e),ge.set(e,n)),n!==void 0?n:ot(t,e)}function G(t,e){if(e==="local"&&t.y>=100)return new Date(t.y,t.M,t.D,t.h,t.m,t.s,t.ms).getTime();let n=ye(t);if(e==="UTC")return n;let r=B(e);if(r!==void 0)return n-r*6e4;let s=C(n-864e5,e),i=C(n+864e5,e),a=new Set([C(n,e),s,i]),o=[];for(let u of a)C(n-u*6e4,e)===u&&o.push(u);return o.length?n-Math.max(...o)*6e4:n-s*6e4}function ut(t){let e=Math.floor(t/864e5),n=t-e*864e5,r=Ae(e),s=Math.floor(n/36e5);n-=s*36e5;let i=Math.floor(n/6e4);n-=i*6e4;let a=Math.floor(n/1e3);return{y:r.y,M:r.M,D:r.D,h:s,m:i,s:a,ms:n-a*1e3,dow:r.dow}}function xe(t,e){return ut(t+e*6e4)}function Q(){return Ue(new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC")}function ue(t){return t%4===0&&t%100!==0||t%400===0}function Ae(t){let e=t+719468,n=Math.floor(e/146097),r=e-n*146097,s=Math.floor((r-Math.floor(r/1460)+Math.floor(r/36524)-Math.floor(r/146096))/365),i=r-(365*s+Math.floor(s/4)-Math.floor(s/100)),a=Math.floor((5*i+2)/153),o=i-Math.floor((153*a+2)/5)+1,u=a<10?a+2:a-10;return{y:s+n*400+(u<=1?1:0),M:u,D:o,dow:(t%7+7+4)%7}}var mt=[31,28,31,30,31,30,31,31,30,31,30,31];function E(t,e){return e===1&&ue(t)?29:mt[e]}function ct(t){return ue(t)?366:365}function K(t,e,n){return Math.round((_(t,e,n)-_(t,0,1))/864e5)+1}function Ye(t,e,n){return new Date(_(t,e,n)).getUTCDay()}function O(t,e,n,r,s){let i=K(t,e,n),a=(Ye(t,e,n)-r+7)%7,o=i-a,u=(Ye(t,0,1)-r+7)%7,m=7-u>=s?1-u:8-u;return o<m?O(t-1,11,31,r,s):o+6-ct(t)>=s?{week:1,year:t+1}:{week:Math.floor((o-m)/7)+1,year:t}}function Re(t,e,n){for(let r=31;r>24;r--){let s=O(t,11,r,e,n);if(s.year===t)return s.week}return 52}var pe={normalizeSpaces:!0},lt=/[\u00a0\u2007\u2009\u202f]/g;function T(t){return pe.normalizeSpaces?t.replace(lt," "):t}var me=Intl,Le=new Map;function $e(t,e="en",n="conjunction",r="long"){if(me.ListFormat){let i=`${e}|${n}|${r}`,a=Le.get(i);return a||(a=new me.ListFormat(e,{type:n,style:r}),Le.set(i,a)),T(a.format(t))}if(t.length<=1)return t.join("");if(n==="unit")return t.join(", ");let s=n==="disjunction"?"or":"and";return t.length===2?`${t[0]} ${s} ${t[1]}`:`${t.slice(0,-1).join(", ")}, ${s} ${t.at(-1)}`}var Ce=new Map;function X(t,e,n,r="long"){let s=`${n}|${e}|${r}`,i=Ce.get(s);if(i===void 0){try{i=new Intl.NumberFormat(n,{style:"unit",unit:e,unitDisplay:r})}catch{i=null}Ce.set(s,i)}return i?T(i.format(t)):`${t} ${e}${Math.abs(t)===1?"":"s"}`}var Ee=new Map;function We(t,e,n,r,s){if(me.RelativeTimeFormat){let o=`${n}|${r}|${s}`,u=Ee.get(o);return u||(u=new me.RelativeTimeFormat(n,{style:r,numeric:s}),Ee.set(o,u)),T(u.format(t,e))}if(s==="auto"){if(t===0)return e==="day"?"today":"now";if(e==="day"&&t===1)return"tomorrow";if(e==="day"&&t===-1)return"yesterday"}let i=Math.abs(t),a=`${i} ${e}${i===1?"":"s"}`;return t<0||Object.is(t,-0)?`${a} ago`:`in ${a}`}var Fe={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",Q:"quarter",y:"year"},Pe=new Set(["millisecond","second","minute","hour","day","date","week","isoWeek","month","quarter","year"]);function N(t){if(t==null)return;if(Fe[t])return Fe[t];if(Pe.has(t))return t;let e=t.toLowerCase().replace(/s$/,"");if(e==="isoweek")return"isoWeek";if(Pe.has(e))return e;throw new RangeError(`neram: unknown unit "${t}"`)}var v=1e3,U=60*v,x=60*U,k=24*x,ee=7*k,De=365.2425*k,te=De/12,ce={millisecond:1,second:v,minute:U,hour:x};function le(t,e){let n=Math.abs(t),r=t<0?-1:1,s=a=>r*Math.round(a);if(n<45*v)return{value:s(n/v),unit:"second"};if(n<45*U)return{value:s(n/U),unit:"minute"};if(n<22*x)return{value:s(n/x),unit:"hour"};if(n<26*k)return{value:s(n/k),unit:"day"};let i=e!==void 0?Math.abs(e):n/te;return i<10.5?{value:s(Math.max(1,i)),unit:"month"}:{value:s(Math.max(1,i/12)),unit:"year"}}function ne(t,e,n,r={}){let s=r.style??"long";return r.withoutSuffix?X(Math.abs(t),e,n,s):We(t,e,n,s,r.numeric??"auto")}var $=["years","months","weeks","days","hours","minutes","seconds","milliseconds"],de="Invalid Duration",ze={years:De,months:te,weeks:ee,days:k,hours:x,minutes:U,seconds:v,milliseconds:1},dt=/^([+-])?P(?:(-?[\d.,]+)Y)?(?:(-?[\d.,]+)M)?(?:(-?[\d.,]+)W)?(?:(-?[\d.,]+)D)?(?:T(?:(-?[\d.,]+)H)?(?:(-?[\d.,]+)M)?(?:(-?[\d.,]+)S)?)?$/i;function he(t){if($.includes(t))return t;switch(N(t)){case"year":return"years";case"quarter":throw new RangeError("neram: use months for quarter durations");case"month":return"months";case"week":case"isoWeek":return"weeks";case"day":case"date":return"days";case"hour":return"hours";case"minute":return"minutes";case"second":return"seconds";default:return"milliseconds"}}var A=class t{#e;constructor(e,n="milliseconds"){let r={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0};if(e instanceof t)Object.assign(r,e.toObject());else if(typeof e=="number")r[he(n)]=e;else if(typeof e=="string"){let s=dt.exec(e.trim());if(!s||e.trim().toUpperCase()==="P"||/T$/i.test(e.trim()))throw new RangeError(`neram: invalid ISO 8601 duration "${e}"`);let i=s[1]==="-"?-1:1;$.forEach((o,u)=>{if(o==="milliseconds")return;let m=s[u+2];m&&(r[o]=i*Number(m.replace(",",".")))});let a=Math.trunc(r.seconds);r.milliseconds=Math.round((r.seconds-a)*1e3),r.seconds=a}else if(e)for(let[s,i]of Object.entries(e))i!=null&&(r[he(s)]+=i);this.#e=r}isValid(){return $.every(e=>Number.isFinite(this.#e[e]))}get years(){return this.#e.years}get months(){return this.#e.months}get weeks(){return this.#e.weeks}get days(){return this.#e.days}get hours(){return this.#e.hours}get minutes(){return this.#e.minutes}get seconds(){return this.#e.seconds}get milliseconds(){return this.#e.milliseconds}get(e){return this.#e[he(e)]}as(e){return this.valueOf()/ze[he(e)]}asMilliseconds(){return this.as("milliseconds")}asSeconds(){return this.as("seconds")}asMinutes(){return this.as("minutes")}asHours(){return this.as("hours")}asDays(){return this.as("days")}asWeeks(){return this.as("weeks")}asMonths(){return this.as("months")}asYears(){return this.as("years")}valueOf(){if(!this.isValid())return NaN;let e=0;for(let n of $)e+=this.#e[n]*ze[n];return e}add(e,n){let r=e instanceof t?e:new t(e,n),s={};for(let i of $)s[i]=this.#e[i]+r.get(i);return new t(s)}subtract(e,n){let r=e instanceof t?e:new t(e,n);return this.add(r.negate())}negate(){let e={};for(let n of $)e[n]=-this.#e[n]||0;return new t(e)}abs(){return this.valueOf()<0?this.negate():this}sign(){let e=this.valueOf();return e===0?0:e<0?-1:1}isZero(){return $.every(e=>this.#e[e]===0)}normalize(){if(!this.isValid())return this;let e=this.#e,n=e.weeks*ee+e.days*k+e.hours*x+e.minutes*U+e.seconds*v+e.milliseconds,r=e.years*12+e.months,s=n<0?-1:1,i=Math.abs(n),a=d=>{let g=Math.floor(i/d);return i-=g*d,s*g||0},o=a(k),u=a(x),m=a(U),l=a(v),c=s*Math.round(i)||0;return new t({years:Math.trunc(r/12)||0,months:r%12||0,days:o,hours:u,minutes:m,seconds:l,milliseconds:c})}humanize(e=!1,n="en"){if(!this.isValid())return de;let r=typeof e=="object"?e:{withoutSuffix:!e},s=this.#e.years*12+this.#e.months,i=this.valueOf()-s*te,{value:a,unit:o}=le(this.valueOf(),i===0&&s!==0?s:void 0);return ne(a,o,r.locale??n,{numeric:"always",...r})}toLocaleString(e="en",n="long"){if(!this.isValid())return de;let r=Intl.DurationFormat;if(r)return T(new r(e,{style:n}).format(this.toObject()));let s=n==="digital"?"narrow":n,i=$.filter(a=>this.#e[a]!==0).map(a=>X(this.#e[a],a.slice(0,-1),e,s));return i.length?$e(i,e,"unit",s):X(0,"second",e,s)}format(e="HH:mm:ss"){if(!this.isValid())return de;let n=this.abs().normalize(),r=(i,a=2)=>String(i).padStart(a,"0"),s=e.replace(/\[([^\]]*)\]|YYYY|Y|MM|M|DD|D|HH|H|mm|m|ss|s|SSS/g,(i,a)=>{if(a!==void 0)return a;switch(i){case"Y":return String(n.years);case"YYYY":return r(n.years,4);case"M":return String(n.months);case"MM":return r(n.months);case"D":return String(n.days);case"DD":return r(n.days);case"H":return String(n.hours);case"HH":return r(n.hours);case"m":return String(n.minutes);case"mm":return r(n.minutes);case"s":return String(n.seconds);case"ss":return r(n.seconds);default:return r(n.milliseconds,3)}});return this.sign()<0?`-${s}`:s}toISOString(){if(!this.isValid())throw new RangeError("neram: invalid duration");let e={...this.#e};e.days+=e.weeks*7;let n=[e.years,e.months,e.days,e.hours,e.minutes,e.seconds+e.milliseconds/1e3],r=n.every(u=>u<=0)&&n.some(u=>u<0),s=r?-1:1,i=u=>String(Math.round(s*u*1e3)/1e3),a="";e.years&&(a+=`${i(e.years)}Y`),e.months&&(a+=`${i(e.months)}M`),e.days&&(a+=`${i(e.days)}D`);let o="";return e.hours&&(o+=`${i(e.hours)}H`),e.minutes&&(o+=`${i(e.minutes)}M`),(e.seconds||e.milliseconds)&&(o+=`${i(e.seconds+e.milliseconds/1e3)}S`),!a&&!o?"PT0S":`${r?"-":""}P${a}${o?`T${o}`:""}`}toJSON(){return this.isValid()?this.toISOString():null}toString(){return this.isValid()?this.toISOString():de}toObject(){return{...this.#e}}};function Z(t,e){return new A(t,e)}function re(t){return t instanceof A}var ht={...j(5,"MV"),...j(6,"AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY"),...j(0,"AG AS BD BR BS BT BW BZ CA CO DM DO ET GT GU HK HN ID IL IN IS JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW")},ft={...j([5],"IR"),...j([0],"IN UG"),...j([4,5],"AF"),...j([5,6],"BH DZ EG IL IQ JO KW LY OM QA SA SD SY YE")},bt=new Set("AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL RE RU SE SJ SK SM VA".split(" ")),gt=["sun","mon","tue","wed","thu","fri","sat"];function j(t,e){return Object.fromEntries(e.split(" ").map(n=>[n,t]))}function yt(t){try{let e=new Intl.Locale(t);return e.region??(typeof e.maximize=="function"?e.maximize().region:void 0)}catch{return/^[a-z]{2,3}[-_]([A-Z]{2})\b/i.exec(t)?.[1].toUpperCase()}}function Ze(t){let e=yt(t)??"001",n=ht[e]??1,r=/-u(?:-[a-z0-9]{2,8})*?-fw-([a-z]{3})\b/i.exec(t);if(r){let s=gt.indexOf(r[1].toLowerCase());s>=0&&(n=s)}return{firstDay:n,minimalDays:bt.has(e)?4:1,weekend:ft[e]??[6,0]}}var je=new Map;function V(t){try{return Intl.getCanonicalLocales(t)[0]??"en"}catch{throw new RangeError(`neram: invalid locale "${t}"`)}}function pt(t){return Ze(t)}function S(t){let e=je.get(t);if(e)return e;let n=w=>new Intl.DateTimeFormat(t,{...w,timeZone:"UTC"}),r=w=>{let M=n(w);return{format:L=>T(M.format(L)),formatToParts:L=>M.formatToParts(L).map(ie=>({...ie,value:T(ie.value)}))}},s=r({month:"long"}),i=r({month:"short"}),a=r({month:"long",day:"numeric"}),o=[],u=[];for(let w=0;w<12;w++){let M=Date.UTC(2021,w,15),L=a.formatToParts(M).find(ie=>ie.type==="month")?.value;o.push(L??s.format(M)),u.push(i.format(M).replace(/\.$/,""))}let m=r({weekday:"long"}),l=r({weekday:"short"}),c=r({weekday:"narrow"}),d=t.toLowerCase().startsWith("en"),g=[],h=[],f=[];for(let w=0;w<7;w++){let M=Date.UTC(2021,0,3+w);g.push(m.format(M));let L=l.format(M).replace(/\.$/,"");h.push(L),f.push(d?L.slice(0,2):c.format(M))}let b=r({hour:"numeric",hour12:!0}),D=w=>b.formatToParts(w).find(M=>M.type==="dayPeriod")?.value,q=[D(Date.UTC(2021,0,1,9))??"AM",D(Date.UTC(2021,0,1,15))??"PM"];return e={months:o,monthsShort:u,weekdays:g,weekdaysShort:h,weekdaysMin:f,meridiem:q,week:pt(t)},je.set(t,e),e}var Ve=new Map,Dt={one:"st",two:"nd",few:"rd",other:"th"};function fe(t,e){if(!e.toLowerCase().startsWith("en"))return`${t}.`;let n=Ve.get(e);return n||(n=new Intl.PluralRules(e,{type:"ordinal"}),Ve.set(e,n)),`${t}${Dt[n.select(t)]??"th"}`}var He=new Map;function we(t){let e=He.get(t);if(e)return e;let n=S(t),r=(a,o)=>u=>u===void 0?a.slice():a[o(u)],s=a=>a.month(),i=a=>a.day();return e=Object.freeze({name:t,firstDayOfWeek:()=>n.week.firstDay,months:r(n.months,s),monthsShort:r(n.monthsShort,s),weekdays:r(n.weekdays,i),weekdaysShort:r(n.weekdaysShort,i),weekdaysMin:r(n.weekdaysMin,i),meridiem:(a,o,u)=>{let m=n.meridiem[a<12?0:1];return u?m.toLocaleLowerCase(t):m},ordinal:a=>fe(a,t),week:()=>({...n.week,weekend:n.week.weekend.slice()})}),He.set(t,e),e}var wt=/\[([^\]]*)\]|LTS|LT|LLLL|LLL|LL|L|llll|lll|ll|l|YYYY|YY|GGGG|gggg|MMMM|MMM|MM|M|Qo|Q|DDDD|DDD|Do|DD|D|dddd|ddd|dd|d|E|HH|H|hh|h|kk|k|mm|m|ss|s|S{1,9}|A|a|ZZ|Z|X|x|WW|W|ww|w|zzz|z/g,y=(t,e=2)=>{let n=String(Math.abs(t)).padStart(e,"0");return t<0?`-${n}`:n},_e={LT:{timeStyle:"short"},LTS:{timeStyle:"medium"},L:{year:"numeric",month:"2-digit",day:"2-digit"},LL:{dateStyle:"long"},LLL:{dateStyle:"long",timeStyle:"short"},LLLL:{dateStyle:"full",timeStyle:"short"},l:{year:"numeric",month:"numeric",day:"numeric"},ll:{dateStyle:"medium"},lll:{dateStyle:"medium",timeStyle:"short"},llll:{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}};function Be(t,e){let{wall:n,locale:r}=t,s,i=()=>s??=S(r),a=()=>O(n.y,n.M,n.D,1,4),o=()=>O(n.y,n.M,n.D,t.weekStart,i().week.minimalDays),u=n.h%12||12,m=d=>{if(_e[d])return t.intl(_e[d]);switch(d){case"YYYY":return n.y>=0&&n.y<=9999?y(n.y,4):(n.y<0?"-":"+")+y(Math.abs(n.y),6);case"YY":return y((n.y%100+100)%100);case"GGGG":return y(a().year,4);case"gggg":return y(o().year,4);case"M":return String(n.M+1);case"MM":return y(n.M+1);case"MMM":return i().monthsShort[n.M];case"MMMM":return i().months[n.M];case"Q":return String(Math.floor(n.M/3)+1);case"Qo":return fe(Math.floor(n.M/3)+1,r);case"D":return String(n.D);case"DD":return y(n.D);case"Do":return fe(n.D,r);case"DDD":return String(K(n.y,n.M,n.D));case"DDDD":return y(K(n.y,n.M,n.D),3);case"d":return String(n.dow);case"E":return String(n.dow||7);case"dd":return i().weekdaysMin[n.dow];case"ddd":return i().weekdaysShort[n.dow];case"dddd":return i().weekdays[n.dow];case"H":return String(n.h);case"HH":return y(n.h);case"h":return String(u);case"hh":return y(u);case"k":return String(n.h||24);case"kk":return y(n.h||24);case"m":return String(n.m);case"mm":return y(n.m);case"s":return String(n.s);case"ss":return y(n.s);case"A":return i().meridiem[n.h<12?0:1];case"a":return i().meridiem[n.h<12?0:1].toLowerCase();case"Z":return P(t.offset);case"ZZ":return P(t.offset,"");case"X":return String(Math.floor(t.ms/1e3));case"x":return String(t.ms);case"W":return String(a().week);case"WW":return y(a().week);case"w":return String(o().week);case"ww":return y(o().week);case"z":return t.intl({timeZoneName:"short"}).split(/,?\s/).pop()??"";case"zzz":return Nt(t);default:return y(n.ms,3).padEnd(d.length,"0").slice(0,d.length)}},l=Mt(e),c=l[0];for(let d=1;d<l.length;d+=2)c+=m(l[d])+l[d+1];return c}var be=new Map;function Mt(t){let e=be.get(t);if(e)return e;e=[];let n="",r=0;for(let s of t.matchAll(wt))n+=t.slice(r,s.index),r=s.index+s[0].length,s[1]!==void 0?n+=s[1]:(e.push(n,s[0]),n="");return e.push(n+t.slice(r)),be.size>500&&be.clear(),be.set(t,e),e}function Nt(t){let e=t.intl({year:"numeric",timeZoneName:"long"}),n=t.intl({year:"numeric"});return e.replace(n,"").replace(/^[\s,]+|[\s,]+$/g,"")}var W={kind:"epoch",ms:NaN},kt=/^([+-]\d{6}|\d{4})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[T\s](\d{2})(?::?(\d{2})(?::?(\d{2})(?:[.,](\d{1,9}))?)?)?)?\s*(Z|[+-]\d{2}(?::?\d{2})?)?(?:\[!?([^\]=]+)\])?(?:\[[^\]]*\])*$/i;function Me(t){return t.M>=0&&t.M<=11&&t.D>=1&&t.D<=E(t.y,t.M)&&t.h>=0&&(t.h<24||t.h===24&&t.m===0&&t.s===0&&t.ms===0)&&t.m>=0&&t.m<60&&t.s>=0&&t.s<61&&t.ms>=0&&t.ms<1e3}function Y(t,e){let n=t.charCodeAt(e)-48,r=t.charCodeAt(e+1)-48;return n>=0&&n<=9&&r>=0&&r<=9?n*10+r:-1}function St(t){let e=t.length;if(e<10||t.charCodeAt(4)!==45||t.charCodeAt(7)!==45)return;let n=Y(t,0),r=Y(t,2),s=Y(t,5),i=Y(t,8);if(n<0||r<0||s<0||i<0)return;let a=0,o=0,u=0,m=0,l,c=10;if(c<e){let g=t.charCodeAt(c);if(g!==84&&g!==116&&g!==32||e<16||t.charCodeAt(13)!==58||(a=Y(t,11),o=Y(t,14),a<0||o<0))return;if(c=16,t.charCodeAt(c)===58){if(u=Y(t,17),u<0)return;if(c=19,t.charCodeAt(c)===46){let h=c+1,f=0,b=0;for(;h<e;h++){let D=t.charCodeAt(h)-48;if(D<0||D>9)break;b<3&&(f=f*10+D),b++}if(b===0||b>9)return;m=b===1?f*100:b===2?f*10:f,c=h}}if(c<e){let h=t.charCodeAt(c);if((h===90||h===122)&&c===e-1)l=0,c++;else if((h===43||h===45)&&e-c===6&&t.charCodeAt(c+3)===58){let f=Y(t,c+1),b=Y(t,c+4);if(f<0||b<0)return;if(f>23||b>59)return W;l=(h===45?-1:1)*(f*60+b),c=e}else return}}let d={y:n*100+r,M:s-1,D:i,h:a,m:o,s:u,ms:m};return Me(d)?(d.s===60&&(d.s=59),{kind:"wall",wall:d,offset:l}):W}function It(t){let e=St(t);if(e)return e;let n=kt.exec(t.trim());if(!n)return;let r={y:Number(n[1]),M:n[2]?Number(n[2])-1:0,D:n[3]?Number(n[3]):1,h:n[4]?Number(n[4]):0,m:n[5]?Number(n[5]):0,s:n[6]?Number(n[6]):0,ms:n[7]?Math.floor(+`0.${n[7]}`*1e3):0};if(!Me(r))return W;r.s===60&&(r.s=59);let s=n[8]?B(n[8].replace(/^([+-]\d{2})$/,"$1:00")):void 0;return n[8]&&s===void 0?W:{kind:"wall",wall:r,offset:s,zone:n[9]}}function Ke(t){let e=It(t);if(e)return e;let n=Date.parse(t);return Number.isNaN(n)?W:{kind:"epoch",ms:n}}var Ot=/\[([^\]]*)\]|YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|dd|HH|H|hh|h|kk|k|mm|m|ss|s|S{1,3}|A|a|ZZ|Z|X|x/g;function J(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(t){return`(${[...t].sort((e,n)=>n.length-e.length).map(J).join("|")})`}var H=t=>(e,n)=>{n[t]=Number(e)};function Je(t,e,n){let r=S(n),s=[],i="",a=0;for(let d of e.matchAll(Ot)){i+=J(e.slice(a,d.index)).replace(/\s+/g,"\\s+"),a=d.index+d[0].length;let g=d[0];if(d[1]!==void 0){i+=J(d[1]);continue}switch(g){case"YYYY":i+="([+-]?\\d{4,6})",s.push(H("y"));break;case"YY":i+="(\\d{2})",s.push((h,f)=>{let b=Number(h);f.y=b+(b>68?1900:2e3)});break;case"MMMM":case"MMM":{i+=Ge([...r.months,...r.monthsShort]),s.push((h,f)=>{let b=h.toLowerCase(),D=r.months.findIndex(q=>q.toLowerCase()===b);D<0&&(D=r.monthsShort.findIndex(q=>q.toLowerCase()===b)),f.M=D+1});break}case"MM":case"M":i+=g==="MM"?"(\\d{2})":"(\\d{1,2})",s.push(H("M"));break;case"Do":i+="(\\d{1,2})(?:st|nd|rd|th|\\.)?",s.push(H("D"));break;case"DD":case"D":i+=g==="DD"?"(\\d{2})":"(\\d{1,2})",s.push(H("D"));break;case"dddd":case"ddd":case"dd":i+=Ge([...r.weekdays,...r.weekdaysShort,...r.weekdaysMin]),s.push(()=>{});break;case"HH":case"H":case"hh":case"h":case"kk":case"k":i+=g.length===2?"(\\d{2})":"(\\d{1,2})",s.push(g[0]==="k"?(h,f)=>{f.h=Number(h)%24}:H("h"));break;case"mm":case"m":i+=g==="mm"?"(\\d{2})":"(\\d{1,2})",s.push(H("m"));break;case"ss":case"s":i+=g==="ss"?"(\\d{2})":"(\\d{1,2})",s.push(H("s"));break;case"A":case"a":i+=`(${J(r.meridiem[0])}|${J(r.meridiem[1])}|am|pm|a\\.m\\.|p\\.m\\.)`,s.push((h,f)=>{let b=h.toLowerCase();f.pm=b===r.meridiem[1].toLowerCase()||b.startsWith("p")});break;case"ZZ":case"Z":i+="(Z|[+-]\\d{2}:?\\d{2})",s.push((h,f)=>{f.offset=B(h)??NaN});break;case"X":i+="(-?\\d+(?:\\.\\d+)?)",s.push((h,f)=>{f.epoch=Number(h)*1e3});break;case"x":i+="(-?\\d+)",s.push((h,f)=>{f.epoch=Number(h)});break;default:i+=`(\\d{1,${g.length}})`,s.push((h,f)=>{f.ms=Math.round(+`0.${h}`*1e3)})}}i+=J(e.slice(a)).replace(/\s+/g,"\\s+");let o=new RegExp(`^\\s*${i}\\s*$`,"i").exec(t);if(!o)return W;let u={};if(s.forEach((d,g)=>d(o[g+1],u)),u.epoch!==void 0)return{kind:"epoch",ms:u.epoch};let m=u.h??0;if(u.pm!==void 0){if(m<1||m>12)return W;u.pm&&m<12&&(m+=12),!u.pm&&m===12&&(m=0)}let l=new Date,c={y:u.y??l.getFullYear(),M:u.M!==void 0?u.M-1:u.y!==void 0?0:l.getMonth(),D:u.D??1,h:m,m:u.m??0,s:u.s??0,ms:u.ms??0};return Me(c)?{kind:"wall",wall:c,offset:u.offset}:W}var p={locale:"en",zone:"local",normalizeSpaces:!0},qe=new Map,I=class t{#e;#t;#n;#l;#d;#b;constructor(e,n,r,s){this.#e=Number.isFinite(e)&&Math.abs(e)<=864e13?e:NaN,this.#t=n,this.#n=r,this.#l=s}#r(e,n=this.#t,r=this.#n,s=this.#l){return new t(e,n,r,s)}#u(){return this.#b??=this.isValid()?C(this.#e,this.#t):NaN}#s(){return this.#d||(this.#d=this.isValid()?xe(this.#e,this.#u()):{y:NaN,M:NaN,D:NaN,h:NaN,m:NaN,s:NaN,ms:NaN,dow:NaN}),this.#d}#i(e){return this.#r(G(e,this.#t))}#m(){return this.#l??p.weekStart??S(this.#n).week.firstDay}#c(e){let n=this.#s(),r=n.y*12+n.M+Xe(e),s=Math.floor(r/12),i=r-s*12;return this.#i({...n,y:s,M:i,D:Math.min(n.D,E(s,i))})}#o(e){let n=this.#s();return this.#i({...n,D:n.D+Xe(e)})}#f(e,n=this.#n){if(!this.isValid())return"Invalid Date";let r=ve(this.#t),s=this.#t==="local"?void 0:r?"UTC":this.#t,i=`${n}|${s}|${JSON.stringify(e)}`,a=qe.get(i);a||(a=new Intl.DateTimeFormat(n,{...e,timeZone:s}),qe.set(i,a));let o=T(a.format(r?this.#e+this.#u()*6e4:this.#e));return r&&e.timeZoneName?o.replace(/UTC|GMT/,`GMT${P(this.#u())}`):o}isValid(){return!Number.isNaN(this.#e)}clone(){return this}get(e){let n=this.#s();switch(N(e)){case"year":return n.y;case"quarter":return Math.floor(n.M/3)+1;case"month":return n.M;case"week":return this.week();case"isoWeek":return this.isoWeek();case"date":return n.D;case"day":return n.dow;case"hour":return n.h;case"minute":return n.m;case"second":return n.s;default:return n.ms}}set(e,n){if(!this.isValid())return this;if(typeof e=="object"){let i=this,a=["year","month","date","day","hour","minute","second","millisecond"];for(let o of a){let u=e[o];u!==void 0&&(i=i.set(o,u))}return i}let r=n,s={...this.#s()};switch(N(e)){case"year":return this.#i({...s,y:r,D:Math.min(s.D,E(r,s.M))});case"quarter":return this.#c((r-(Math.floor(s.M/3)+1))*3);case"month":{let i=s.y+Math.floor(r/12),a=(r%12+12)%12;return this.#i({...s,y:i,M:a,D:Math.min(s.D,E(i,a))})}case"week":return this.#o((r-this.week())*7);case"isoWeek":return this.#o((r-this.isoWeek())*7);case"date":return this.#i({...s,D:r});case"day":return this.#o(r-s.dow);case"hour":return this.#i({...s,h:r});case"minute":return this.#i({...s,m:r});case"second":return this.#i({...s,s:r});default:return this.#i({...s,ms:r})}}year(e){return e===void 0?this.get("year"):this.set("year",e)}month(e){return e===void 0?this.get("month"):this.set("month",e)}date(e){return e===void 0?this.get("date"):this.set("date",e)}day(e){return e===void 0?this.get("day"):this.set("day",e)}hour(e){return e===void 0?this.get("hour"):this.set("hour",e)}minute(e){return e===void 0?this.get("minute"):this.set("minute",e)}second(e){return e===void 0?this.get("second"):this.set("second",e)}millisecond(e){return e===void 0?this.get("millisecond"):this.set("millisecond",e)}quarter(e){return e===void 0?this.get("quarter"):this.set("quarter",e)}dayOfYear(e){let n=this.#s(),r=K(n.y,n.M,n.D);return e===void 0?r:this.#o(e-r)}isoWeekday(e){let n=this.#s().dow||7;return e===void 0?n:this.#o(e-n)}weekday(e){let n=(this.#s().dow-this.#m()+7)%7;return e===void 0?n:this.#o(e-n)}week(){let e=this.#s();return O(e.y,e.M,e.D,this.#m(),S(this.#n).week.minimalDays).week}weekYear(){let e=this.#s();return O(e.y,e.M,e.D,this.#m(),S(this.#n).week.minimalDays).year}isoWeek(){let e=this.#s();return O(e.y,e.M,e.D,1,4).week}isoWeekYear(){let e=this.#s();return O(e.y,e.M,e.D,1,4).year}isoWeeksInYear(){return Re(this.year(),1,4)}daysInMonth(){let e=this.#s();return E(e.y,e.M)}isLeapYear(){return ue(this.year())}add(e,n){if(!this.isValid())return this;if(typeof e!="number"){let s=re(e)?e:Z(e);if(!s.isValid())return this.#r(NaN);let i=s.toObject(),a=this;(i.years||i.months)&&(a=a.#c(i.years*12+i.months)),(i.weeks||i.days)&&(a=a.#o(i.weeks*7+i.days));let o=i.hours*36e5+i.minutes*6e4+i.seconds*1e3+i.milliseconds;return o?a.#r(a.#e+o):a}let r=N(n??"millisecond");switch(r){case"year":return this.#c(e*12);case"quarter":return this.#c(e*3);case"month":return this.#c(e);case"week":case"isoWeek":return this.#o(e*7);case"day":case"date":return this.#o(e);default:return this.#r(this.#e+e*(ce[r]??1))}}subtract(e,n){return typeof e=="number"?this.add(-e,n):this.add((re(e)?e:Z(e)).negate())}startOf(e){if(!this.isValid())return this;let n=N(e),r={...this.#s()},s={h:0,m:0,s:0,ms:0};switch(n){case"year":return this.#i({...r,...s,M:0,D:1});case"quarter":return this.#i({...r,...s,M:Math.floor(r.M/3)*3,D:1});case"month":return this.#i({...r,...s,D:1});case"week":return this.#i({...r,...s,D:r.D-(r.dow-this.#m()+7)%7});case"isoWeek":return this.#i({...r,...s,D:r.D-(r.dow+6)%7});case"day":case"date":return this.#i({...r,...s});case"hour":return this.#r(this.#e-(r.m*6e4+r.s*1e3+r.ms));case"minute":return this.#r(this.#e-(r.s*1e3+r.ms));case"second":return this.#r(this.#e-r.ms);default:return this}}endOf(e){let n=N(e);return n==="millisecond"?this:this.startOf(n).add(1,n==="date"?"day":n).subtract(1,"millisecond")}round(e){if(!this.isValid())return this;let n=N(e),r=this.startOf(n),s=r.add(1,n==="date"?"day":n);return this.#e-r.#e<s.#e-this.#e?r:s}clamp(e,n){let r=this.#a(e),s=this.#a(n);return this.#e<r.#e?r.tz(this.#t):this.#e>s.#e?s.tz(this.#t):this}tz(e,n=!1){let r=z(e);return this.isValid()?n?this.#r(G(this.#s(),r),r):this.#r(this.#e,r):this.#r(NaN,r)}utc(e=!1){return this.tz("UTC",e)}local(e=!1){return this.tz("local",e)}timezone(){return this.#t==="local"?Q():this.#t}isUTC(){return this.#t==="UTC"}isLocal(){return this.#t==="local"}utcOffset(e,n=!1){if(e===void 0)return this.#u();let r;if(typeof e=="string"){r=z(e)==="UTC"?0:Number.NaN;let s=/^([+-])(\d{2}):?(\d{2})$/.exec(e);s&&(r=(s[1]==="-"?-1:1)*(Number(s[2])*60+Number(s[3])))}else r=Math.abs(e)<16?e*60:e;if(Number.isNaN(r))throw new RangeError(`neram: invalid offset "${e}"`);return this.tz(r===0?"UTC":P(r),n)}isDST(){if(!this.isValid())return!1;let e=this.year(),n=C(Date.UTC(e,0,1),this.#t),r=C(Date.UTC(e,6,1),this.#t);return n!==r&&this.#u()===Math.max(n,r)}localeData(){return we(this.#n)}locale(e){return e===void 0?this.#n:this.#r(this.#e,this.#t,V(e))}weekStart(e){return e===void 0?this.#m():this.#r(this.#e,this.#t,this.#n,e)}format(e="YYYY-MM-DDTHH:mm:ssZ"){return this.isValid()?Be({wall:this.#s(),ms:this.#e,offset:this.#u(),locale:this.#n,weekStart:this.#m(),intl:n=>this.#f(n)},e):"Invalid Date"}toLocaleString(e={dateStyle:"medium",timeStyle:"medium"},n){return this.#f(e,n?V(n):this.#n)}from(e,n={}){if(!this.isValid())return"Invalid Date";let r=this.#a(e);if(!r.isValid())return"Invalid Date";let s=this.#e-r.#e,{value:i,unit:a}=le(s,this.diff(r,"month",!0));return ne(i,a,n.locale??this.#n,n)}fromNow(e={}){return this.from(this.#r(Date.now()),e)}to(e,n={}){return this.isValid()?this.#a(e).locale(this.#n).from(this,n):"Invalid Date"}toNow(e={}){return this.to(this.#r(Date.now()),e)}calendar(e,n={}){if(!this.isValid())return"Invalid Date";let r=(e===void 0?this.#r(Date.now()):this.#a(e)).tz(this.#t),s=this.startOf("day").diff(r.startOf("day"),"day"),i=this.#n.toLowerCase().startsWith("en"),a=i?" at ":" ",o=this.format("LT"),u=l=>l.charAt(0).toLocaleUpperCase(this.#n)+l.slice(1);if(Math.abs(s)<=1)return u(ne(s,"day",this.#n))+a+o;let m=S(this.#n).weekdays[this.day()];return s>1&&s<7?u(m)+a+o:s<-1&&s>-7?(i?`Last ${m}`:u(m))+a+o:this.format(n.sameElse??"L")}#a(e){return e instanceof t?e:F(e,{zone:this.#t,locale:this.#n})}diff(e,n="millisecond",r=!1){let s=this.#a(e);if(!this.isValid()||!s.isValid())return NaN;let i=N(n),a=this.#e+this.#u()*6e4-(s.#e+s.#u()*6e4),o;switch(i){case"year":o=se(this,s)/12;break;case"quarter":o=se(this,s)/3;break;case"month":o=se(this,s);break;case"week":case"isoWeek":o=a/ee;break;case"day":case"date":o=a/k;break;default:o=(this.#e-s.#e)/(ce[i]??1)}return r?o:Math.trunc(o)||0}durationTo(e){let n=this.#a(e);if(!this.isValid()||!n.isValid())return Z(NaN);let r=n.#e<this.#e?-1:1,[s,i]=r>0?[this,n]:[n,this],a=Math.trunc(se(i,s));s=s.add(a,"month");let o=Math.trunc(i.diff(s,"day"));s=s.add(o,"day");let u=i.#e-s.#e;return Z({months:r*a,days:r*o,milliseconds:r*u}).normalize()}isBefore(e,n){let r=this.#a(e);return n?this.endOf(n).#e<r.#e:this.#e<r.#e}isAfter(e,n){let r=this.#a(e);return n?this.startOf(n).#e>r.#e:this.#e>r.#e}isSame(e,n){let r=this.#a(e);return n?this.startOf(n).#e<=r.#e&&r.#e<=this.endOf(n).#e:this.#e===r.#e}isSameOrBefore(e,n){return this.isSame(e,n)||this.isBefore(e,n)}isSameOrAfter(e,n){return this.isSame(e,n)||this.isAfter(e,n)}isBetween(e,n,r,s="()"){let[i,a]=[this.#a(e),this.#a(n)].sort((m,l)=>m.#e-l.#e),o=s[0]==="["?this.isSameOrAfter(i,r):this.isAfter(i,r),u=s[1]==="]"?this.isSameOrBefore(a,r):this.isBefore(a,r);return o&&u}isToday(){return this.isSame(this.#r(Date.now()),"day")}isTomorrow(){return this.isSame(this.#r(Date.now()).add(1,"day"),"day")}isYesterday(){return this.isSame(this.#r(Date.now()).subtract(1,"day"),"day")}isPast(){return this.#e<Date.now()}isFuture(){return this.#e>Date.now()}isWeekend(e){return(e===void 0?S(this.#n).week.weekend:Ne(e)).includes(this.day())}isBusinessDay(e={}){return this.isWeekend(e.weekend)?!1:e.holidays?.length?!this.#h(e).has(this.format("YYYY-MM-DD")):!0}addBusinessDays(e,n={}){if(!Number.isInteger(e))throw new RangeError(`neram: business days must be a whole number, got ${e}`);n.weekend!==void 0&&Ne(n.weekend);let r=this.#h(n);if(!this.isValid())return this;let s=e<0?-1:1,i=Math.abs(e),a=this;for(;i>0;)a=a.#o(s),!a.isWeekend(n.weekend)&&!r.has(a.format("YYYY-MM-DD"))&&i--;return a}subtractBusinessDays(e,n={}){return this.addBusinessDays(-e,n)}businessDaysUntil(e,n={}){n.weekend!==void 0&&Ne(n.weekend);let r=this.#a(e);if(!this.isValid()||!r.isValid())return NaN;let s=r.tz(this.#t).startOf("day"),i=this.startOf("day"),a=s.#e<i.#e?-1:1,o=this.#h(n),u=0;for(;a>0?i.#e<s.#e:i.#e>s.#e;)i=i.#o(a),!i.isWeekend(n.weekend)&&!o.has(i.format("YYYY-MM-DD"))&&(u+=a);return u}#h(e){return new Set((e.holidays??[]).map(n=>{let r=this.#a(n);if(!r.isValid())throw new RangeError(`neram: invalid holiday ${JSON.stringify(n)}`);return r.tz(this.#t).format("YYYY-MM-DD")}))}valueOf(){return this.#e}unix(){return Math.floor(this.#e/1e3)}toDate(){return new Date(this.#e)}toISOString(){return new Date(this.#e).toISOString()}toZonedISOString(){if(!this.isValid())return"Invalid Date";let e=this.#s().ms?".SSS":"";return`${this.format(`YYYY-MM-DDTHH:mm:ss${e}Z`)}[${this.timezone()}]`}toTemporal(){let e=globalThis.Temporal;if(!e)throw new Error("neram: Temporal is not available in this runtime");return e.ZonedDateTime.from(this.toZonedISOString())}toJSON(){return this.isValid()?this.toISOString():null}toString(){return this.isValid()?new Date(this.#e).toUTCString():"Invalid Date"}toObject(){let e=this.#s();return{year:e.y,month:e.M,date:e.D,hour:e.h,minute:e.m,second:e.s,millisecond:e.ms}}toArray(){let e=this.#s();return[e.y,e.M,e.D,e.h,e.m,e.s,e.ms]}[Symbol.toPrimitive](e){return e==="number"?this.#e:this.toString()}get[Symbol.toStringTag](){return"Neram"}};function se(t,e){if(t.date()<e.date())return-se(e,t);let n=(e.year()-t.year())*12+(e.month()-t.month()),r=t.add(n,"month").valueOf(),s=e.valueOf()-r<0,i=t.add(n+(s?-1:1),"month").valueOf();return-(n+(e.valueOf()-r)/(s?r-i:i-r))||0}function Qe(t,e,n){if(t.kind==="epoch")return{ms:t.ms,zone:e};let r=e;return t.zone&&!n&&(r=z(t.zone)),t.offset!==void 0?{ms:ye(t.wall)-t.offset*6e4,zone:r}:{ms:G(t.wall,r),zone:r}}function Tt(t){return typeof t=="object"&&t!==null&&typeof t.epochMilliseconds=="number"}function R(t,e,n,r){let s={};typeof e=="string"||Array.isArray(e)?s.format=e:e&&(s={...e}),typeof n=="boolean"?s.strict=n:typeof n=="string"&&(s.locale=n),typeof r=="boolean"&&(s.strict=r);let i=s.locale?V(s.locale):p.locale,a=s.utc===!0||s.zone!==void 0,o=z(s.utc?"UTC":s.zone??p.zone),u=s.weekStart;if(t instanceof I){let l=t;return a&&(l=l.tz(o)),s.locale&&(l=l.locale(i)),u!==void 0&&(l=l.weekStart(u)),l}let m;if(t===void 0)m=Date.now();else if(t===null)m=NaN;else if(t instanceof Date)m=t.getTime();else if(typeof t=="number")m=t;else if(typeof t=="string"){let l=s.format===void 0?void 0:Array.isArray(s.format)?s.format:[s.format];if(!l)({ms:m,zone:o}=Qe(Ke(t),o,a));else{m=NaN;for(let c of l){let d=Qe(Je(t,c,i),o,a);if(!Number.isNaN(d.ms)&&!(s.strict&&new I(d.ms,d.zone,i,u).format(c)!==t.trim())){({ms:m,zone:o}=d);break}}}}else if(Array.isArray(t)){let[l=new Date().getFullYear(),c=0,d=1,g=0,h=0,f=0,b=0]=t,D={y:l,M:c,D:d,h:g,m:h,s:f,ms:b};m=t.length>=1&&t.length<=7&&et(D)?G(D,o):NaN}else if(Tt(t))m=t.epochMilliseconds,t.timeZoneId&&!a&&(o=z(t.timeZoneId));else if(typeof t=="object"){let l=Ut(t),c=l&&{y:l.year??new Date().getFullYear(),M:l.month??0,D:l.date??1,h:l.hour??0,m:l.minute??0,s:l.second??0,ms:l.millisecond??0};m=c&&et(c)?G(c,o):NaN}else m=NaN;return new I(m,o,i,u)}function Xe(t){return t<0?-Math.round(-t):Math.round(t)}function Ne(t){if(!Array.isArray(t)||t.some(e=>!Number.isInteger(e)||e<0||e>6))throw new RangeError(`neram: weekend must list weekday numbers 0-6 (0 = Sunday), got ${JSON.stringify(t)}`);if(new Set(t).size===7)throw new RangeError("neram: weekend cannot include every day of the week");return t}var vt={year:"year",years:"year",y:"year",month:"month",months:"month",M:"month",date:"date",dates:"date",D:"date",d:"date",day:"date",days:"date",hour:"hour",hours:"hour",h:"hour",minute:"minute",minutes:"minute",m:"minute",second:"second",seconds:"second",s:"second",millisecond:"millisecond",milliseconds:"millisecond",ms:"millisecond"};function Ut(t){let e={},n=!1;for(let[r,s]of Object.entries(t)){if(s===void 0)continue;let i=vt[r];if(!i||typeof s!="number"||e[i]!==void 0)return;e[i]=s,n=!0}return n?e:void 0}function et(t){return[t.y,t.M,t.D,t.h,t.m,t.s,t.ms].every(Number.isInteger)?t.M>=0&&t.M<=11&&t.D>=1&&t.D<=E(t.y,t.M)&&t.h>=0&&t.h<=23&&t.m>=0&&t.m<=59&&t.s>=0&&t.s<=59&&t.ms>=0&&t.ms<=999:!1}var tt=new Set;function nt(t){return(t.length===1&&Array.isArray(t[0])&&typeof t[0][0]!="number"?t[0]:t).map(e=>R(e)).filter(e=>e.isValid())}var F=Object.assign(R,{utc(t,e,n){return R(t,{format:e,strict:n,utc:!0})},tz(t,e,n){return R(t,{format:n,zone:e})},unix(t){return R(t*1e3)},now(){return R()},duration:Z,isDuration:re,Duration:A,Neram:I,isNeram(t){return t instanceof I},min(...t){let e=nt(t);return e.length?e.reduce((n,r)=>r.valueOf()<n.valueOf()?r:n):null},max(...t){let e=nt(t);return e.length?e.reduce((n,r)=>r.valueOf()>n.valueOf()?r:n):null},sort(t){return t.map(e=>R(e)).sort((e,n)=>e.valueOf()-n.valueOf())},range(t,e,n={}){let r=N(n.unit??"day"),s=n.step??1;if(typeof s!="number"||!Number.isFinite(s)||s<=0)throw new RangeError(`neram: range step must be a positive number, got ${String(s)}`);if(!(r in ce)&&!Number.isInteger(s))throw new RangeError(`neram: range step must be a whole number of ${r}s, got ${s}`);let i=n.limit??1e5;if(!Number.isInteger(i)||i<0)throw new RangeError(`neram: range limit must be a whole number, got ${i}`);let a=R(t),o=R(e);if(!a.isValid()||!o.isValid())return[];let u=s*(o.valueOf()<a.valueOf()?-1:1),m=[];for(let l=0;;l++){let c=a.add(u*l,r);if((u>0?c.valueOf()>o.valueOf():c.valueOf()<o.valueOf())||n.exclusive&&c.valueOf()===o.valueOf())break;if(m.length===i)throw new RangeError(`neram: range has more than ${i} dates; use a larger step or pass { limit }`);m.push(c)}return m},locale(t){return t!==void 0&&(p.locale=V(t)),p.locale},localeData(t){return we(t?V(t):p.locale)},environment(){let t=globalThis.process?.versions??{},e=Intl,n=!0;try{new Intl.NumberFormat("en",{style:"unit",unit:"hour"})}catch{n=!1}return{zone:Q(),defaultZone:p.zone==="local"?Q():p.zone,locale:p.locale,runtimeLocale:new Intl.DateTimeFormat().resolvedOptions().locale,icu:t.icu,cldr:t.cldr,tzdata:t.tz,features:{relativeTimeFormat:typeof e.RelativeTimeFormat=="function",listFormat:typeof e.ListFormat=="function",durationFormat:typeof e.DurationFormat=="function",supportedValuesOf:typeof e.supportedValuesOf=="function",unitFormat:n}}},guess(){return Q()},zones(){let t=Intl.supportedValuesOf;return t?t("timeZone"):[]},config(t={}){return t.locale!==void 0&&(p.locale=V(t.locale)),t.zone!==void 0&&(p.zone=z(t.zone)),"weekStart"in t&&(p.weekStart=t.weekStart),t.normalizeSpaces!==void 0&&(pe.normalizeSpaces=p.normalizeSpaces=t.normalizeSpaces),{...p}},extend(t,e){return tt.has(t)||(t(e,I,F),tt.add(t)),F}});Object.assign(F,{Neram:I,Duration:A});globalThis.neram=F;})();
|