@bereasoftware/time-guard 2.6.1 → 2.7.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.
Files changed (98) hide show
  1. package/README.en.md +232 -0
  2. package/README.md +259 -4
  3. package/dist/angular/index.cjs +148 -0
  4. package/dist/angular/index.d.ts +2 -0
  5. package/dist/angular/index.es.js +143 -0
  6. package/dist/angular.d.ts +59 -0
  7. package/dist/calendars/index.cjs +357 -2
  8. package/dist/calendars/index.es.js +99 -68
  9. package/dist/chunk-Ddh6569R.cjs +36 -0
  10. package/dist/core-BAd7GYfw.js +1809 -0
  11. package/dist/core-CafqOI7W.cjs +1892 -0
  12. package/dist/core.d.ts +224 -0
  13. package/dist/index.d.ts +9 -0
  14. package/dist/locales/african.locale.d.ts +7 -0
  15. package/dist/locales/index.cjs +7 -1
  16. package/dist/{types/locales → locales}/index.d.ts +2 -2
  17. package/dist/locales/index.es.js +3 -3
  18. package/dist/locales/south-american.locale.d.ts +7 -0
  19. package/dist/locales-C2-lOmC8.cjs +3537 -0
  20. package/dist/{locales-DSBvgSaw.js → locales-CcuSu4P1.js} +749 -33
  21. package/dist/native/index.cjs +48 -0
  22. package/dist/native/index.d.ts +2 -0
  23. package/dist/native/index.es.js +18 -0
  24. package/dist/native.d.ts +9 -0
  25. package/dist/plugins/advanced-format.cjs +105 -2
  26. package/dist/plugins/advanced-format.es.js +63 -45
  27. package/dist/plugins/duration.cjs +258 -2
  28. package/dist/plugins/duration.es.js +165 -61
  29. package/dist/plugins/relative-time.cjs +166 -2
  30. package/dist/plugins/relative-time.es.js +74 -37
  31. package/dist/qwik/index.cjs +104 -0
  32. package/dist/qwik/index.d.ts +2 -0
  33. package/dist/qwik/index.es.js +100 -0
  34. package/dist/qwik.d.ts +32 -0
  35. package/dist/react/index.cjs +112 -0
  36. package/dist/react/index.d.ts +2 -0
  37. package/dist/react/index.es.js +103 -0
  38. package/dist/react.d.ts +46 -0
  39. package/dist/solid/index.cjs +127 -0
  40. package/dist/solid/index.d.ts +2 -0
  41. package/dist/solid/index.es.js +122 -0
  42. package/dist/solid.d.ts +53 -0
  43. package/dist/svelte/index.cjs +398 -0
  44. package/dist/svelte/index.d.ts +2 -0
  45. package/dist/svelte/index.es.js +393 -0
  46. package/dist/svelte.d.ts +88 -0
  47. package/dist/time-guard.cjs +7359 -4
  48. package/dist/time-guard.es.js +3625 -8085
  49. package/dist/time-guard.iife.js +13549 -4
  50. package/dist/time-guard.umd.js +13550 -4
  51. package/dist/types/index.d.ts +651 -127
  52. package/dist/vue/index.cjs +143 -0
  53. package/dist/vue/index.d.ts +2 -0
  54. package/dist/vue/index.es.js +137 -0
  55. package/dist/vue.d.ts +35 -0
  56. package/package.json +107 -27
  57. package/dist/calendars/index.cjs.map +0 -1
  58. package/dist/calendars/index.es.js.map +0 -1
  59. package/dist/locales-DSBvgSaw.js.map +0 -1
  60. package/dist/locales-ybx7jS8G.cjs +0 -2
  61. package/dist/locales-ybx7jS8G.cjs.map +0 -1
  62. package/dist/plugins/advanced-format.cjs.map +0 -1
  63. package/dist/plugins/advanced-format.es.js.map +0 -1
  64. package/dist/plugins/duration.cjs.map +0 -1
  65. package/dist/plugins/duration.es.js.map +0 -1
  66. package/dist/plugins/relative-time.cjs.map +0 -1
  67. package/dist/plugins/relative-time.es.js.map +0 -1
  68. package/dist/time-guard.cjs.map +0 -1
  69. package/dist/time-guard.es.js.map +0 -1
  70. package/dist/time-guard.iife.js.map +0 -1
  71. package/dist/time-guard.umd.js.map +0 -1
  72. package/dist/types/types/index.d.ts +0 -641
  73. /package/dist/{types/adapters → adapters}/temporal.adapter.d.ts +0 -0
  74. /package/dist/{types/calendars → calendars}/calendar.manager.d.ts +0 -0
  75. /package/dist/{types/calendars → calendars}/index.d.ts +0 -0
  76. /package/dist/{types/formatters → formatters}/date.formatter.d.ts +0 -0
  77. /package/dist/{types/locales → locales}/additional.locale.d.ts +0 -0
  78. /package/dist/{types/locales → locales}/asian.locale.d.ts +0 -0
  79. /package/dist/{types/locales → locales}/english.locale.d.ts +0 -0
  80. /package/dist/{types/locales → locales}/european.locale.d.ts +0 -0
  81. /package/dist/{types/locales → locales}/locale.manager.d.ts +0 -0
  82. /package/dist/{types/locales → locales}/middle-eastern.locale.d.ts +0 -0
  83. /package/dist/{types/locales → locales}/nordic.locale.d.ts +0 -0
  84. /package/dist/{types/locales → locales}/romance.locale.d.ts +0 -0
  85. /package/dist/{types/locales → locales}/slavic.locale.d.ts +0 -0
  86. /package/dist/{types/locales → locales}/spanish.locale.d.ts +0 -0
  87. /package/dist/{types/plugins → plugins}/advanced-format/index.d.ts +0 -0
  88. /package/dist/{types/plugins → plugins}/advanced-format.d.ts +0 -0
  89. /package/dist/{types/plugins → plugins}/duration/index.d.ts +0 -0
  90. /package/dist/{types/plugins → plugins}/duration/types.d.ts +0 -0
  91. /package/dist/{types/plugins → plugins}/duration.d.ts +0 -0
  92. /package/dist/{types/plugins → plugins}/index.d.ts +0 -0
  93. /package/dist/{types/plugins → plugins}/manager.d.ts +0 -0
  94. /package/dist/{types/plugins → plugins}/relative-time/index.d.ts +0 -0
  95. /package/dist/{types/plugins → plugins}/relative-time/types.d.ts +0 -0
  96. /package/dist/{types/plugins → plugins}/relative-time.d.ts +0 -0
  97. /package/dist/{types/time-guard.d.ts → time-guard.d.ts} +0 -0
  98. /package/dist/{types/utils → utils}/duration-locale.d.ts +0 -0
package/dist/core.d.ts ADDED
@@ -0,0 +1,224 @@
1
+ import { ITimeGuard, ITimeGuardConfig, Unit, FormatPreset, IRoundOptions, IDurationOptions, DurationParts, IDiffResult, IDiffOptions, IDurationExplanation, IFormattableDuration, TemporalPlainDateTime, TemporalZonedDateTime } from './types';
2
+ import { LocaleManager, EN_LOCALE, ES_LOCALE } from './locales/locale.manager';
3
+ /**
4
+ * Diff result object that allows chaining with .as()
5
+ *
6
+ * Supports two modes:
7
+ * - 'exact': Returns precise time differences
8
+ * - 'calendar': Returns calendar-aware breakdown
9
+ */
10
+ declare class DiffResult implements IDiffResult, IFormattableDuration {
11
+ private _value;
12
+ private _tg1;
13
+ private _tg2;
14
+ private _mode;
15
+ private _breakdownData;
16
+ private _locale;
17
+ constructor(value: number, tg1: TimeGuard, tg2: TimeGuard, mode?: 'calendar' | 'exact', breakdownData?: DurationParts, locale?: string);
18
+ as(unit: Unit): number;
19
+ breakdown(): DurationParts | null;
20
+ format(locale?: string): string;
21
+ getMode(): 'calendar' | 'exact';
22
+ valueOf(): number;
23
+ toString(): string;
24
+ toJSON(): number;
25
+ }
26
+ /**
27
+ * DurationResult class - Represents a duration breakdown with humanize support
28
+ * Returned by until(), since(), and between() methods
29
+ */
30
+ export declare class DurationResult implements DurationParts, IFormattableDuration {
31
+ years: number;
32
+ months: number;
33
+ weeks: number;
34
+ days: number;
35
+ hours: number;
36
+ minutes: number;
37
+ seconds: number;
38
+ milliseconds: number;
39
+ private _locale;
40
+ private _startDate?;
41
+ private _endDate?;
42
+ private _steps;
43
+ private _mode;
44
+ private _leapYearFlags;
45
+ private _calculationTimeMs;
46
+ constructor(parts: DurationParts, locale?: string, metadata?: {
47
+ startDate?: string;
48
+ endDate?: string;
49
+ steps?: string[];
50
+ mode?: 'exact' | 'estimated';
51
+ leapYearFlags?: Array<{
52
+ year: number;
53
+ isLeap: boolean;
54
+ daysInFebruary: number;
55
+ }>;
56
+ calculationTimeMs?: number;
57
+ });
58
+ humanize(options?: {
59
+ locale?: string;
60
+ fullBreakdown?: boolean;
61
+ numeric?: 'always' | 'auto';
62
+ }): string;
63
+ total(unit: Unit): number;
64
+ toString(): string;
65
+ toJSON(): Record<string, number>;
66
+ explain(): IDurationExplanation;
67
+ private generateExplanationSteps;
68
+ private pluralizeUnit;
69
+ }
70
+ /**
71
+ * TimeRange - Fluent API for date range operations
72
+ *
73
+ * @example
74
+ * TimeGuard.range('2024-01-15', '2024-03-20')
75
+ * .toDuration().humanize() // "2 months and 5 days"
76
+ * .inMonths() // 2.1355 (precise decimal)
77
+ */
78
+ export declare class TimeRange {
79
+ private _start;
80
+ private _end;
81
+ constructor(start: TimeGuard, end: TimeGuard);
82
+ get start(): TimeGuard;
83
+ get end(): TimeGuard;
84
+ private getOrdered;
85
+ toDuration(): DurationResult;
86
+ inMonths(): number;
87
+ humanize(options?: {
88
+ locale?: string;
89
+ fullBreakdown?: boolean;
90
+ numeric?: 'always' | 'auto';
91
+ }): string;
92
+ in(unit: Unit): number;
93
+ contains(date: unknown): boolean;
94
+ overlaps(other: TimeRange): boolean;
95
+ intersect(other: TimeRange): TimeRange | null;
96
+ union(other: TimeRange): TimeRange;
97
+ }
98
+ /**
99
+ * TimeGuard implementation - Main facade class
100
+ */
101
+ export declare class TimeGuard implements ITimeGuard {
102
+ private temporal;
103
+ private config;
104
+ private formatterInstance;
105
+ private static holidays;
106
+ static registerHolidays(dates: string[]): void;
107
+ static clearHolidays(): void;
108
+ static getRegisteredHolidays(): string[];
109
+ private static readonly ZERO_DURATION;
110
+ private static isLeapYearValue;
111
+ private static toDurationParts;
112
+ constructor(input?: unknown, config?: ITimeGuardConfig);
113
+ static now(config?: ITimeGuardConfig): TimeGuard;
114
+ static from(input: unknown, config?: ITimeGuardConfig): TimeGuard;
115
+ static fromTemporal(temporal: TemporalPlainDateTime | TemporalZonedDateTime, config?: ITimeGuardConfig): TimeGuard;
116
+ /**
117
+ * Calculate duration between two dates - always returns positive duration
118
+ *
119
+ * @example
120
+ * TimeGuard.between(start, end).humanize() // "2 months and 5 days"
121
+ * TimeGuard.between(end, start).humanize() // "2 months and 5 days" (still positive)
122
+ */
123
+ static between(date1: TimeGuard, date2: TimeGuard): DurationResult;
124
+ /**
125
+ * Create a TimeRange for fluent duration calculations
126
+ *
127
+ * @example
128
+ * TimeGuard.range("2024-01-15", "2024-03-20").humanize() // "2 months and 5 days"
129
+ */
130
+ static range(start: unknown, end: unknown): TimeRange;
131
+ toTemporal(): TemporalPlainDateTime | TemporalZonedDateTime;
132
+ toDate(): Date;
133
+ toISOString(): string;
134
+ valueOf(): number;
135
+ unix(): number;
136
+ toJSON(): string;
137
+ [Symbol.toPrimitive](hint: 'default' | 'string' | 'number'): string | number;
138
+ toString(): string;
139
+ locale(): string;
140
+ locale(locale: string): TimeGuard;
141
+ timezone(): string | null;
142
+ timezone(timezone: string): TimeGuard;
143
+ format(pattern: string | FormatPreset): string;
144
+ get(component: Unit): number;
145
+ /** Map from singular Unit to plural Temporal polyfill key */
146
+ private static readonly UNIT_TO_PLURAL;
147
+ add(units: Partial<Record<Unit, number>>): TimeGuard;
148
+ subtract(units: Partial<Record<Unit, number>>): TimeGuard;
149
+ diff(other: TimeGuard): DiffResult;
150
+ diff(other: TimeGuard, unit: Unit): number;
151
+ diff(other: TimeGuard, options: IDiffOptions): DiffResult;
152
+ isBefore(other: TimeGuard): boolean;
153
+ isAfter(other: TimeGuard): boolean;
154
+ isSame(other: TimeGuard, unit?: Unit): boolean;
155
+ isBetween(start: TimeGuard, end: TimeGuard, unit?: Unit, inclusivity?: '[)' | '()' | '[]' | '(]'): boolean;
156
+ clone(): TimeGuard;
157
+ startOf(unit: Unit): TimeGuard;
158
+ endOf(unit: Unit): TimeGuard;
159
+ set(values: Partial<Record<Unit, number>>): TimeGuard;
160
+ year(): number;
161
+ month(): number;
162
+ day(): number;
163
+ hour(): number;
164
+ minute(): number;
165
+ second(): number;
166
+ millisecond(): number;
167
+ dayOfWeek(): number;
168
+ dayOfYear(): number;
169
+ weekOfYear(): number;
170
+ daysInMonth(): number;
171
+ daysInYear(): number;
172
+ inLeapYear(): boolean;
173
+ until(other: TimeGuard, options?: IDurationOptions): DurationResult;
174
+ private generateUntilSteps;
175
+ round(options?: IRoundOptions): TimeGuard;
176
+ toPlainDate(): {
177
+ year: number;
178
+ month: number;
179
+ day: number;
180
+ dayOfWeek: number;
181
+ };
182
+ toPlainTime(): {
183
+ hour: number;
184
+ minute: number;
185
+ second: number;
186
+ millisecond: number;
187
+ };
188
+ withDate(year: number, month: number, day: number): TimeGuard;
189
+ withTime(hour: number, minute?: number, second?: number, millisecond?: number): TimeGuard;
190
+ getOffset(): string;
191
+ getOffsetNanoseconds(): number;
192
+ getTimeZoneId(): string | null;
193
+ startOfDay(): TimeGuard;
194
+ endOfDay(): TimeGuard;
195
+ since(other: TimeGuard, options?: IDurationOptions): DurationResult;
196
+ toDurationString(other?: TimeGuard): string;
197
+ isPast(): boolean;
198
+ isFuture(): boolean;
199
+ isToday(): boolean;
200
+ isTomorrow(): boolean;
201
+ isYesterday(): boolean;
202
+ isWeekend(): boolean;
203
+ isHoliday(): boolean;
204
+ isBusinessDay(): boolean;
205
+ addBusinessDays(days: number): TimeGuard;
206
+ subtractBusinessDays(days: number): TimeGuard;
207
+ }
208
+ export type { ITimeGuard, ITimeGuardConfig, ITimeGuardFactory, ITimeGuardPlugin, IDateParser, IDateFormatter, ILocaleManager, IDateArithmetic, IDateQuery, IDateManipulation, ITimezoneAdapter, ICalendarSystem, ICalendarManager, IRoundOptions, IDurationOptions, IDurationResult, IDurationExplanation, IHumanizeOptions, IDiffResult, IDiffOptions, DurationParts, Unit, FormatPreset, ILocale, } from './types';
209
+ export { TemporalAdapter } from './adapters/temporal.adapter';
210
+ export { LocaleManager, EN_LOCALE, ES_LOCALE };
211
+ export { getAvailableLocales, LOCALES_COUNT, ALL_LOCALES, registerAllLocales, } from './locales/index';
212
+ export { DateFormatter } from './formatters/date.formatter';
213
+ export { CalendarManager, GregorianCalendar, calendarManager, } from './calendars/calendar.manager';
214
+ export { IslamicCalendar, HebrewCalendar, ChineseCalendar, JapaneseCalendar, BuddhistCalendar, } from './calendars/index';
215
+ export * from './plugins/index';
216
+ export { PluginManager } from './plugins/manager';
217
+ export { RelativeTimePlugin, default as relativeTimePlugin, } from './plugins/relative-time';
218
+ export type { RelativeTimeConfig, RelativeTimeFormats, RelativeTimeThreshold, } from './plugins/relative-time/types';
219
+ export { DurationPlugin, Duration, default as durationPlugin, } from './plugins/duration';
220
+ export type { IDuration, DurationInput, DurationObject, DurationUnit, } from './plugins/duration/types';
221
+ export { AdvancedFormatPlugin, default as advancedFormatPlugin, } from './plugins/advanced-format';
222
+ export declare function timeGuard(input?: unknown, config?: ITimeGuardConfig): TimeGuard;
223
+ /** The current version of TimeGuard */
224
+ export declare const version: string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * TimeGuard - Modern date/time library using Temporal API
3
+ * Full bundle (backward compatible)
4
+ * Includes: core + all locales + all plugins + all calendars + polyfill (auto-loaded)
5
+ *
6
+ * @author Berea-Soft
7
+ * @license MIT
8
+ */
9
+ export * from './core';
@@ -0,0 +1,7 @@
1
+ import { ILocale } from '../types';
2
+ export declare const SW_LOCALE_DATA: ILocale;
3
+ export declare const AF_LOCALE_DATA: ILocale;
4
+ export declare const ZU_LOCALE_DATA: ILocale;
5
+ export declare const AM_LOCALE_DATA: ILocale;
6
+ export declare const YO_LOCALE_DATA: ILocale;
7
+ export declare const AFRICAN_LOCALES: Record<string, ILocale>;
@@ -1 +1,7 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../locales-ybx7jS8G.cjs`);exports.ALL_LOCALES=e.t,exports.LOCALES_COUNT=e.n,exports.getAvailableLocales=e.r,exports.registerAllLocales=e.i;
1
+ /*! time-guard v2.7.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const require_locales = require("../locales-C2-lOmC8.cjs");
4
+ exports.ALL_LOCALES = require_locales.ALL_LOCALES;
5
+ exports.LOCALES_COUNT = require_locales.LOCALES_COUNT;
6
+ exports.getAvailableLocales = require_locales.getAvailableLocales;
7
+ exports.registerAllLocales = require_locales.registerAllLocales;
@@ -12,6 +12,6 @@ export declare function registerAllLocales(localeMap: Map<string, ILocale> | Rec
12
12
  */
13
13
  export declare function getAvailableLocales(): string[];
14
14
  /**
15
- * Total locales count (minimum 40 required)
15
+ * Total locales count
16
16
  */
17
- export declare const LOCALES_COUNT = 40;
17
+ export declare const LOCALES_COUNT: number;
@@ -1,3 +1,3 @@
1
- /*! time-guard v2.6.1 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
2
- import { i as e, n as t, r as n, t as r } from "../locales-DSBvgSaw.js";
3
- export { r as ALL_LOCALES, t as LOCALES_COUNT, n as getAvailableLocales, e as registerAllLocales };
1
+ /*! time-guard v2.7.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
2
+ import { i as registerAllLocales, n as LOCALES_COUNT, r as getAvailableLocales, t as ALL_LOCALES } from "../locales-CcuSu4P1.js";
3
+ export { ALL_LOCALES, LOCALES_COUNT, getAvailableLocales, registerAllLocales };
@@ -0,0 +1,7 @@
1
+ import { ILocale } from '../types';
2
+ export declare const ES_419_LOCALE_DATA: ILocale;
3
+ export declare const QU_LOCALE_DATA: ILocale;
4
+ export declare const GN_LOCALE_DATA: ILocale;
5
+ export declare const AY_LOCALE_DATA: ILocale;
6
+ export declare const ARN_LOCALE_DATA: ILocale;
7
+ export declare const SOUTH_AMERICAN_LOCALES: Record<string, ILocale>;