@weekwise/adapter-luxon 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 weekwise contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,76 @@
1
- # Temporary Holding Version
1
+ # @weekwise/adapter-luxon
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 📖 **[Documentation and live examples](https://weekwise.dev/guides/date-adapters/)** on [weekwise.dev](https://weekwise.dev)
4
+
5
+ [Luxon](https://moment.github.io/luxon) adapter for the weekwise calendar. It implements
6
+ the `DateAdapter` interface from `@weekwise/core`.
7
+
8
+ ```bash
9
+ npm install @weekwise/adapter-luxon luxon
10
+ ```
11
+
12
+ `luxon` (3.4 or later) is a peer dependency, so your app controls its version.
13
+
14
+ ## Usage
15
+
16
+ ```tsx
17
+ import { LuxonAdapter } from "@weekwise/adapter-luxon";
18
+
19
+ // React
20
+ <DateLocalizationProvider adapter={LuxonAdapter}>…</DateLocalizationProvider>
21
+
22
+ // with a language
23
+ const adapter = new LuxonAdapter({ locale: "fr" });
24
+ <DateLocalizationProvider adapter={adapter}>…</DateLocalizationProvider>
25
+ ```
26
+
27
+ ## Localization
28
+
29
+ Pass a BCP 47 locale string. Luxon formats with the browser's `Intl`, so there are no locale
30
+ files to import. The locale sets:
31
+
32
+ - month and weekday names;
33
+ - date and time formats: built-in patterns use Luxon macro tokens (`D`, `DDD`, `t`, `f`),
34
+ so `en-US` gets `5/15/2024, 2:30 PM`, `en-GB` `15/05/2024, 14:30`, `ru` `15.05.2024, 14:30`;
35
+ - the first day of the week (`adapter.weekStartsOn`, from `Intl.Locale` week info), the
36
+ calendar's default `startWeek`;
37
+ - `adapter.locale`, which the calendar uses to pick its interface language and to format
38
+ toolbar headings.
39
+
40
+ Without a locale the adapter uses `en-GB`: day-first dates, 24-hour time, weeks from Monday.
41
+
42
+ ## Time zone
43
+
44
+ `timeZone` shows the calendar in an IANA time zone: days start at its midnight and times are
45
+ its wall-clock times, wherever the user is. Dates stay `Date`s, that is moments in time.
46
+
47
+ ```ts
48
+ new LuxonAdapter({ locale: "en-US", timeZone: "America/New_York" });
49
+ ```
50
+
51
+ ```ts
52
+ const ruAdapter = new LuxonAdapter({ locale: "ru" });
53
+ const sameFormatsInGerman = ruAdapter.withLocale("de"); // keeps `formats` overrides
54
+ ```
55
+
56
+ ## Formats
57
+
58
+ Override any built-in pattern with [Luxon tokens](https://moment.github.io/luxon/#/formatting?id=table-of-tokens):
59
+
60
+ ```ts
61
+ new LuxonAdapter({ formats: { timeShort: "HH:mm", weekdayShort: "ccccc" } });
62
+ ```
63
+
64
+ | Pattern | Default | Used for |
65
+ | --- | --- | --- |
66
+ | `timeShort` | `t` | Hour labels, now line, drag preview |
67
+ | `date` | `D` | Drag preview |
68
+ | `weekdayShort` | `ccc` | Column headers, date picker |
69
+ | `dateTime`, `dateTimeShort`, `dateTimeLong` | `F`, `f`, `ff` | Your own `format(date, "dateTime")` calls |
70
+ | `dateLong`, `dateShort`, `time`, `monthLong`, `month`, `dayNum`, `weekdayLong`, `timeCompact` | | Your own formatting |
71
+
72
+ `formatDistanceToNow` returns Luxon's relative time with its direction (`"1 hour ago"`).
73
+
74
+ ## License
75
+
76
+ MIT
@@ -0,0 +1,100 @@
1
+ import { type DateAdapter, type DateFormatPattern, type DateFormatPatterns, type WeekDay } from "@weekwise/core";
2
+ type DateInput = Date | number | string;
3
+ export interface LuxonAdapterOptions {
4
+ /**
5
+ * BCP 47 locale, e.g. `"ru"`, `"en-US"`: month and weekday names, date/time formats and the
6
+ * first day of the week come from the browser's Intl data, so no locale files are imported.
7
+ * The calendar picks its interface language by it too. Defaults to `"en-GB"`.
8
+ *
9
+ * @example
10
+ * new LuxonAdapter({ locale: "ru" });
11
+ */
12
+ locale?: string;
13
+ /**
14
+ * IANA time zone the calendar shows, e.g. `"America/New_York"`: days start at its midnight
15
+ * and times are its wall-clock times. Dates stay `Date`s (moments in time). Defaults to the
16
+ * runtime's zone.
17
+ */
18
+ timeZone?: string;
19
+ /** Overrides of the built-in patterns, in Luxon tokens: `{ timeShort: "h:mm a" }`. */
20
+ formats?: Partial<DateFormatPatterns>;
21
+ }
22
+ /**
23
+ * {@link DateAdapter} implementation backed by Luxon.
24
+ */
25
+ export default class LuxonAdapter implements DateAdapter {
26
+ readonly locale: string;
27
+ readonly weekStartsOn: WeekDay;
28
+ readonly timeZone?: string;
29
+ readonly formatPatterns: DateFormatPatterns;
30
+ constructor(options?: LuxonAdapterOptions);
31
+ /** Same settings with another locale, e.g. when the user switches the interface language. */
32
+ withLocale(locale: string): LuxonAdapter;
33
+ private _formatOverrides;
34
+ private _resolve;
35
+ /** Luxon's zone option: the adapter's zone, else the runtime's. */
36
+ private get _zone();
37
+ /**
38
+ * A Luxon DateTime in the adapter's locale and time zone. Strings are read as ISO 8601,
39
+ * in that zone when they have no offset.
40
+ */
41
+ private _dt;
42
+ private _isSame;
43
+ toMillis(date: DateInput): number;
44
+ fromMillis(millis: number): Date;
45
+ format(date: DateInput, formatOrPatternKey?: DateFormatPattern | (string & {})): string;
46
+ formatDistanceToNow(date: DateInput): string;
47
+ tryFormat(date: DateInput, formatOrPatternKey?: DateFormatPattern | (string & {})): string | null;
48
+ parse(dateString: string, formatOrPatternKey?: DateFormatPattern | (string & {})): Date;
49
+ tryParse(dateString: string, formatOrPatternKey?: DateFormatPattern | (string & {})): Date | null;
50
+ parseISO(date: string): Date;
51
+ weekDayShortName(value: number): string;
52
+ monthShortName(value: DateInput): string;
53
+ monthFullName(value: DateInput): string;
54
+ getNow(date?: number | string): Date;
55
+ getEndOfMonth(date?: DateInput): Date;
56
+ getWeekDay(date?: DateInput): number;
57
+ getMonthDay(date?: DateInput): number;
58
+ getYears(date?: DateInput): number;
59
+ getMonths(date?: DateInput): number;
60
+ getHours(date?: DateInput): number;
61
+ getMinutes(date?: DateInput): number;
62
+ getSeconds(date?: DateInput): number;
63
+ getMilliseconds(date?: DateInput): number;
64
+ getToday(): Date;
65
+ getStartOfDay(date?: DateInput): Date;
66
+ getStartOfMonth(date?: DateInput): Date;
67
+ getStartOfWeek(date?: DateInput, weekStart?: WeekDay): Date;
68
+ getEndOfWeek(date?: DateInput, weekStart?: WeekDay): Date;
69
+ getStartOfYearPeriod(date?: DateInput, period?: number): Date;
70
+ getDifferenceInMinutes(left: DateInput, right?: DateInput): number;
71
+ addYears(date: DateInput, count: number): Date;
72
+ addMonths(date: DateInput, count: number): Date;
73
+ addDays(date: DateInput, count: number): Date;
74
+ addHours(date: DateInput, count: number): Date;
75
+ addMinutes(date: DateInput, count: number): Date;
76
+ addSeconds(date: DateInput, count: number): Date;
77
+ setYears(date: DateInput, year: number): Date;
78
+ setMonths(date: DateInput, month: number): Date;
79
+ setMonthDay(date: DateInput, day: number): Date;
80
+ setHours(date: DateInput, hour: number): Date;
81
+ setMinutes(date: DateInput, minute: number): Date;
82
+ setSeconds(date: DateInput, second: number): Date;
83
+ setMilliseconds(date: DateInput, millisecond: number): Date;
84
+ isBefore(date1: DateInput, date2?: DateInput): boolean;
85
+ isAfter(date1: DateInput, date2?: DateInput): boolean;
86
+ isValid(date: DateInput): boolean;
87
+ isMatch(date: string, formatOrPatternKey?: DateFormatPattern | (string & {})): boolean;
88
+ isToday(date: DateInput): boolean;
89
+ isSameMonth(left: DateInput, right?: DateInput): boolean;
90
+ isSameDay(left: DateInput, right?: DateInput): boolean;
91
+ isSameYear(left: DateInput, right?: DateInput): boolean;
92
+ isSameHour(left: DateInput, right?: DateInput): boolean;
93
+ isSameMinute(left: DateInput, right?: DateInput): boolean;
94
+ isSameSecond(left: DateInput, right?: DateInput): boolean;
95
+ isDateInRange(date: DateInput, isSame: (left: DateInput, right: DateInput) => boolean, start?: DateInput, end?: DateInput): boolean;
96
+ isSameDate(left: DateInput, right?: DateInput): boolean;
97
+ isSameDateTime(left: DateInput, right?: DateInput): boolean;
98
+ isEqual(left: DateInput, right?: DateInput): boolean;
99
+ }
100
+ export {};
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("luxon"),t=require("@weekwise/core");var n={dayNum:`dd`,weekdayLong:`cccc`,weekdayShort:`ccc`,monthLong:`LLLL`,month:`LLL`,dateTimeShort:`f`,dateTime:`F`,dateTimeLong:`ff`,date:`D`,dateLong:`DDD`,dateShort:`d MMMM`,time:`tt`,timeShort:`t`,timeCompact:`t`},r=class r{constructor(t={}){this.locale=t.locale??`en-GB`,this.timeZone=t.timeZone,this.weekStartsOn=e.Info.getStartOfWeek({locale:this.locale})%7,this.formatPatterns={...n,...t.formats};for(let e=Object.getPrototypeOf(this);e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e)){let n=Object.getOwnPropertyDescriptor(e,t);t!==`constructor`&&typeof n?.value==`function`&&!Object.prototype.hasOwnProperty.call(this,t)&&Object.defineProperty(this,t,{value:n.value.bind(this),writable:!0,configurable:!0})}}withLocale(e){return new r({locale:e,timeZone:this.timeZone,formats:this._formatOverrides()})}_formatOverrides(){let e={};for(let t of Object.keys(n))this.formatPatterns[t]!==n[t]&&(e[t]=this.formatPatterns[t]);return e}_resolve(e){return e in this.formatPatterns?this.formatPatterns[e]:e}get _zone(){return this.timeZone??`default`}_dt(n=new Date){let r={zone:this._zone,locale:this.locale};return(0,t.isString)(n)?e.DateTime.fromISO(n,r):typeof n==`number`?e.DateTime.fromMillis(n,r):e.DateTime.fromJSDate(n,r)}_isSame(e,t,n){return this._dt(e).hasSame(this._dt(t),n)}toMillis(e){return this._dt(e).toMillis()}fromMillis(e){return new Date(e)}format(e,t=this.formatPatterns.dateTime){let n=this._dt(e);if(!n.isValid)throw RangeError(`Invalid time value`);return n.toFormat(this._resolve(t))}formatDistanceToNow(e){return this._dt(e).toRelative()??``}tryFormat(e,t=this.formatPatterns.dateTime){return this.isValid(e)?this.format(e,t):null}parse(t,n=this.formatPatterns.dateTime){return e.DateTime.fromFormat(t,this._resolve(n),{locale:this.locale,zone:this._zone}).toJSDate()}tryParse(e,t=this.formatPatterns.dateTime){let n=this.parse(e,t);return Number.isNaN(n.getTime())?null:n}parseISO(t){return e.DateTime.fromISO(t,{zone:this._zone}).toJSDate()}weekDayShortName(t){return this.format(e.DateTime.fromObject({year:2024,month:1,day:7+t,hour:12},{zone:this._zone}).toJSDate(),`weekdayShort`)}monthShortName(e){return this._dt(e).toFormat(`LLL`)}monthFullName(e){return this._dt(e).toFormat(`LLLL`)}getNow(e){return e?new Date(e):new Date}getEndOfMonth(e){return this._dt(e).endOf(`month`).toJSDate()}getWeekDay(e){return this._dt(e).weekday%7}getMonthDay(e){return this._dt(e).day}getYears(e){return this._dt(e).year}getMonths(e){return this._dt(e).month-1}getHours(e){return this._dt(e).hour}getMinutes(e){return this._dt(e).minute}getSeconds(e){return this._dt(e).second}getMilliseconds(e){return this._dt(e).millisecond}getToday(){return this._dt().startOf(`day`).toJSDate()}getStartOfDay(e){return this._dt(e).startOf(`day`).toJSDate()}getStartOfMonth(e){return this._dt(e).startOf(`month`).toJSDate()}getStartOfWeek(e,t=this.weekStartsOn){let n=this._dt(e).startOf(`day`);return n.minus({days:(n.weekday%7-t+7)%7}).toJSDate()}getEndOfWeek(e,t=this.weekStartsOn){return this._dt(this.getStartOfWeek(e,t)).plus({days:6}).endOf(`day`).toJSDate()}getStartOfYearPeriod(e,t=0){let n=this._dt(e).startOf(`year`);return t?n.set({year:Math.floor(n.year/t)*t}).toJSDate():n.toJSDate()}getDifferenceInMinutes(e,t){return Math.trunc(this._dt(e).diff(this._dt(t),`minutes`).minutes)}addYears(e,t){return this._dt(e).plus({years:t}).toJSDate()}addMonths(e,t){return this._dt(e).plus({months:t}).toJSDate()}addDays(e,t){return this._dt(e).plus({days:t}).toJSDate()}addHours(e,t){return this._dt(e).plus({hours:t}).toJSDate()}addMinutes(e,t){return this._dt(e).plus({minutes:t}).toJSDate()}addSeconds(e,t){return this._dt(e).plus({seconds:t}).toJSDate()}setYears(e,t){return this._dt(e).set({year:t}).toJSDate()}setMonths(e,t){return this._dt(e).set({month:t+1}).toJSDate()}setMonthDay(e,t){return this._dt(e).set({day:t}).toJSDate()}setHours(e,t){return this._dt(e).set({hour:t}).toJSDate()}setMinutes(e,t){return this._dt(e).set({minute:t}).toJSDate()}setSeconds(e,t){return this._dt(e).set({second:t}).toJSDate()}setMilliseconds(e,t){return this._dt(e).set({millisecond:t}).toJSDate()}isBefore(e,t){return this._dt(e)<this._dt(t)}isAfter(e,t){return this._dt(e)>this._dt(t)}isValid(e){return this._dt(e).isValid}isMatch(t,n=this.formatPatterns.dateTime){return e.DateTime.fromFormat(t,this._resolve(n),{locale:this.locale,zone:this._zone}).isValid}isToday(e){return this._isSame(e,void 0,`day`)}isSameMonth(e,t){return this._isSame(e,t,`month`)}isSameDay(e,t){return this._isSame(e,t,`day`)}isSameYear(e,t){return this._isSame(e,t,`year`)}isSameHour(e,t){return this._isSame(e,t,`hour`)}isSameMinute(e,t){return this._isSame(e,t,`minute`)}isSameSecond(e,t){return this._isSame(e,t,`second`)}isDateInRange(e,t,n,r){return n&&r?t(e,n)||t(e,r)||this.isAfter(e,n)&&this.isBefore(e,r):n&&t(e,n)||r&&t(e,r)||!1}isSameDate(e,t){return this.isSameDay(e,t)}isSameDateTime(e,t){return this.isSameSecond(e,t)}isEqual(e,t){return this._dt(e).toMillis()===this._dt(t).toMillis()}};exports.LuxonAdapter=r,exports.default=r;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["Info","isString","DateTime","luxon","_weekwise_core","DEFAULT_FORMATS","LuxonAdapter","options","proto","name","descriptor","locale","overrides","key","formatOrPatternKey","value","left","right","unit","date","millis","dateString","weekStart","day","period","yearStart","count","year","month","hour","minute","second","millisecond","date1","date2","isSame","start","end"],"sources":["../src/LuxonAdapter.ts"],"sourcesContent":["import { DateTime, Info, type DateTimeUnit } from \"luxon\";\n\nimport {\n isString,\n type DateAdapter,\n type DateFormatPattern,\n type DateFormatPatterns,\n type WeekDay,\n} from \"@weekwise/core\";\n\ntype DateInput = Date | number | string;\n\nexport interface LuxonAdapterOptions {\n /**\n * BCP 47 locale, e.g. `\"ru\"`, `\"en-US\"`: month and weekday names, date/time formats and the\n * first day of the week come from the browser's Intl data, so no locale files are imported.\n * The calendar picks its interface language by it too. Defaults to `\"en-GB\"`.\n *\n * @example\n * new LuxonAdapter({ locale: \"ru\" });\n */\n locale?: string;\n /**\n * IANA time zone the calendar shows, e.g. `\"America/New_York\"`: days start at its midnight\n * and times are its wall-clock times. Dates stay `Date`s (moments in time). Defaults to the\n * runtime's zone.\n */\n timeZone?: string;\n /** Overrides of the built-in patterns, in Luxon tokens: `{ timeShort: \"h:mm a\" }`. */\n formats?: Partial<DateFormatPatterns>;\n}\n\n/**\n * Built-in patterns. `D`/`DDD` (date), `t`/`tt` (time) and `f`/`F`/`ff` (date and time) are\n * Luxon macro tokens, so every locale gets its own order, separators and 12/24-hour clock.\n */\nconst DEFAULT_FORMATS: DateFormatPatterns = {\n dayNum: \"dd\",\n weekdayLong: \"cccc\",\n weekdayShort: \"ccc\",\n monthLong: \"LLLL\",\n month: \"LLL\",\n dateTimeShort: \"f\",\n dateTime: \"F\",\n dateTimeLong: \"ff\",\n date: \"D\",\n dateLong: \"DDD\",\n dateShort: \"d MMMM\",\n time: \"tt\",\n timeShort: \"t\",\n timeCompact: \"t\",\n};\n\n/**\n * {@link DateAdapter} implementation backed by Luxon.\n */\nexport default class LuxonAdapter implements DateAdapter {\n readonly locale: string;\n readonly weekStartsOn: WeekDay;\n readonly timeZone?: string;\n readonly formatPatterns: DateFormatPatterns;\n\n constructor(options: LuxonAdapterOptions = {}) {\n this.locale = options.locale ?? \"en-GB\";\n this.timeZone = options.timeZone;\n // Luxon numbers weekdays 1 (Monday) … 7 (Sunday)\n this.weekStartsOn = (Info.getStartOfWeek({ locale: this.locale }) % 7) as WeekDay;\n this.formatPatterns = { ...DEFAULT_FORMATS, ...options.formats };\n\n // The calendar destructures adapter methods (`const { format } = adapter`)\n for (let proto = Object.getPrototypeOf(this); proto && proto !== Object.prototype; proto = Object.getPrototypeOf(proto)) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (name !== \"constructor\" && typeof descriptor?.value === \"function\" && !Object.prototype.hasOwnProperty.call(this, name)) {\n Object.defineProperty(this, name, { value: descriptor.value.bind(this), writable: true, configurable: true });\n }\n }\n }\n }\n\n /** Same settings with another locale, e.g. when the user switches the interface language. */\n public withLocale(locale: string): LuxonAdapter {\n return new LuxonAdapter({ locale, timeZone: this.timeZone, formats: this._formatOverrides() });\n }\n\n private _formatOverrides(): Partial<DateFormatPatterns> {\n const overrides: Partial<DateFormatPatterns> = {};\n for (const key of Object.keys(DEFAULT_FORMATS) as DateFormatPattern[]) {\n if (this.formatPatterns[key] !== DEFAULT_FORMATS[key]) overrides[key] = this.formatPatterns[key];\n }\n return overrides;\n }\n\n private _resolve(formatOrPatternKey: string): string {\n return formatOrPatternKey in this.formatPatterns\n ? this.formatPatterns[formatOrPatternKey as DateFormatPattern]\n : formatOrPatternKey;\n }\n\n /** Luxon's zone option: the adapter's zone, else the runtime's. */\n private get _zone() {\n return this.timeZone ?? \"default\";\n }\n\n /**\n * A Luxon DateTime in the adapter's locale and time zone. Strings are read as ISO 8601,\n * in that zone when they have no offset.\n */\n private _dt(value: DateInput = new Date()): DateTime {\n const options = { zone: this._zone, locale: this.locale };\n return isString(value)\n ? DateTime.fromISO(value, options)\n : typeof value === \"number\"\n ? DateTime.fromMillis(value, options)\n : DateTime.fromJSDate(value, options);\n }\n\n private _isSame(left: DateInput, right: DateInput | undefined, unit: DateTimeUnit): boolean {\n return this._dt(left).hasSame(this._dt(right), unit);\n }\n\n public toMillis(date: DateInput): number {\n return this._dt(date).toMillis();\n }\n\n public fromMillis(millis: number): Date {\n return new Date(millis);\n }\n\n public format(\n date: DateInput,\n formatOrPatternKey: DateFormatPattern | (string & {}) = this.formatPatterns.dateTime\n ) {\n const value = this._dt(date);\n if (!value.isValid) throw new RangeError(\"Invalid time value\");\n return value.toFormat(this._resolve(formatOrPatternKey));\n }\n\n public formatDistanceToNow(date: DateInput) {\n return this._dt(date).toRelative() ?? \"\";\n }\n\n public tryFormat(\n date: DateInput,\n formatOrPatternKey: DateFormatPattern | (string & {}) = this.formatPatterns.dateTime\n ) {\n if (!this.isValid(date)) return null;\n return this.format(date, formatOrPatternKey);\n }\n\n public parse(\n dateString: string,\n formatOrPatternKey: DateFormatPattern | (string & {}) = this.formatPatterns.dateTime\n ): Date {\n return DateTime.fromFormat(dateString, this._resolve(formatOrPatternKey), {\n locale: this.locale,\n zone: this._zone,\n }).toJSDate();\n }\n\n public tryParse(\n dateString: string,\n formatOrPatternKey: DateFormatPattern | (string & {}) = this.formatPatterns.dateTime\n ) {\n const date = this.parse(dateString, formatOrPatternKey);\n return Number.isNaN(date.getTime()) ? null : date;\n }\n\n public parseISO(date: string): Date {\n return DateTime.fromISO(date, { zone: this._zone }).toJSDate();\n }\n\n public weekDayShortName(value: number): string {\n // 7 January 2024 is a Sunday: built in the adapter's zone, where a local midnight can be the day before\n return this.format(DateTime.fromObject({ year: 2024, month: 1, day: 7 + value, hour: 12 }, { zone: this._zone }).toJSDate(), \"weekdayShort\");\n }\n\n public monthShortName(value: DateInput): string {\n return this._dt(value).toFormat(\"LLL\");\n }\n\n public monthFullName(value: DateInput): string {\n return this._dt(value).toFormat(\"LLLL\");\n }\n\n // Get\n public getNow(date?: number | string): Date {\n return date ? new Date(date) : new Date();\n }\n\n public getEndOfMonth(date?: DateInput): Date {\n return this._dt(date).endOf(\"month\").toJSDate();\n }\n\n public getWeekDay(date?: DateInput) {\n return this._dt(date).weekday % 7;\n }\n\n public getMonthDay(date?: DateInput): number {\n return this._dt(date).day;\n }\n\n public getYears(date?: DateInput): number {\n return this._dt(date).year;\n }\n\n public getMonths(date?: DateInput) {\n // Luxon months are 1-based\n return this._dt(date).month - 1;\n }\n\n public getHours(date?: DateInput): number {\n return this._dt(date).hour;\n }\n\n public getMinutes(date?: DateInput): number {\n return this._dt(date).minute;\n }\n\n public getSeconds(date?: DateInput): number {\n return this._dt(date).second;\n }\n\n public getMilliseconds(date?: DateInput): number {\n return this._dt(date).millisecond;\n }\n\n public getToday(): Date {\n return this._dt().startOf(\"day\").toJSDate();\n }\n\n public getStartOfDay(date?: DateInput): Date {\n return this._dt(date).startOf(\"day\").toJSDate();\n }\n\n public getStartOfMonth(date?: DateInput): Date {\n return this._dt(date).startOf(\"month\").toJSDate();\n }\n\n public getStartOfWeek(date?: DateInput, weekStart: WeekDay = this.weekStartsOn): Date {\n const day = this._dt(date).startOf(\"day\");\n return day.minus({ days: ((day.weekday % 7) - weekStart + 7) % 7 }).toJSDate();\n }\n\n public getEndOfWeek(date?: DateInput, weekStart: WeekDay = this.weekStartsOn): Date {\n return this._dt(this.getStartOfWeek(date, weekStart))\n .plus({ days: 6 })\n .endOf(\"day\")\n .toJSDate();\n }\n\n public getStartOfYearPeriod(date?: DateInput, period = 0) {\n const yearStart = this._dt(date).startOf(\"year\");\n if (period) {\n return yearStart.set({ year: Math.floor(yearStart.year / period) * period }).toJSDate();\n }\n\n return yearStart.toJSDate();\n }\n\n public getDifferenceInMinutes(left: DateInput, right?: DateInput): number {\n return Math.trunc(this._dt(left).diff(this._dt(right), \"minutes\").minutes);\n }\n\n public addYears(date: DateInput, count: number): Date {\n return this._dt(date).plus({ years: count }).toJSDate();\n }\n\n public addMonths(date: DateInput, count: number): Date {\n return this._dt(date).plus({ months: count }).toJSDate();\n }\n\n public addDays(date: DateInput, count: number): Date {\n return this._dt(date).plus({ days: count }).toJSDate();\n }\n\n public addHours(date: DateInput, count: number): Date {\n return this._dt(date).plus({ hours: count }).toJSDate();\n }\n\n public addMinutes(date: DateInput, count: number): Date {\n return this._dt(date).plus({ minutes: count }).toJSDate();\n }\n\n public addSeconds(date: DateInput, count: number): Date {\n return this._dt(date).plus({ seconds: count }).toJSDate();\n }\n\n public setYears(date: DateInput, year: number): Date {\n return this._dt(date).set({ year }).toJSDate();\n }\n\n public setMonths(date: DateInput, month: number): Date {\n return this._dt(date).set({ month: month + 1 }).toJSDate();\n }\n\n public setMonthDay(date: DateInput, day: number): Date {\n return this._dt(date).set({ day }).toJSDate();\n }\n\n public setHours(date: DateInput, hour: number): Date {\n return this._dt(date).set({ hour }).toJSDate();\n }\n\n public setMinutes(date: DateInput, minute: number): Date {\n return this._dt(date).set({ minute }).toJSDate();\n }\n\n public setSeconds(date: DateInput, second: number): Date {\n return this._dt(date).set({ second }).toJSDate();\n }\n\n public setMilliseconds(date: DateInput, millisecond: number): Date {\n return this._dt(date).set({ millisecond }).toJSDate();\n }\n\n public isBefore(date1: DateInput, date2?: DateInput): boolean {\n return this._dt(date1) < this._dt(date2);\n }\n\n public isAfter(date1: DateInput, date2?: DateInput): boolean {\n return this._dt(date1) > this._dt(date2);\n }\n\n public isValid(date: DateInput): boolean {\n return this._dt(date).isValid;\n }\n\n public isMatch(\n date: string,\n formatOrPatternKey: DateFormatPattern | (string & {}) = this.formatPatterns.dateTime\n ): boolean {\n return DateTime.fromFormat(date, this._resolve(formatOrPatternKey), { locale: this.locale, zone: this._zone })\n .isValid;\n }\n\n public isToday(date: DateInput): boolean {\n return this._isSame(date, undefined, \"day\");\n }\n\n public isSameMonth(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"month\");\n }\n\n public isSameDay(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"day\");\n }\n\n public isSameYear(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"year\");\n }\n\n public isSameHour(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"hour\");\n }\n\n public isSameMinute(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"minute\");\n }\n\n public isSameSecond(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"second\");\n }\n\n public isDateInRange(\n date: DateInput,\n isSame: (left: DateInput, right: DateInput) => boolean,\n start?: DateInput,\n end?: DateInput\n ) {\n if (start && end) {\n return (\n isSame(date, start) ||\n isSame(date, end) ||\n (this.isAfter(date, start) && this.isBefore(date, end))\n );\n }\n return (start && isSame(date, start)) || (end && isSame(date, end)) || false;\n }\n\n public isSameDate(left: DateInput, right?: DateInput) {\n return this.isSameDay(left, right);\n }\n\n public isSameDateTime(left: DateInput, right?: DateInput) {\n return this.isSameSecond(left, right);\n }\n\n public isEqual(left: DateInput, right?: DateInput) {\n return this._dt(left).toMillis() === this._dt(right).toMillis();\n }\n}\n"],"mappings":"A,kJAoCA,IAAMK,EAAsC,CAC1C,OAAQ,KACR,YAAa,OACb,aAAc,MACd,UAAW,OACX,MAAO,MAC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,CAC/D,OAAO,KAAK,QAAQD,EAAMC,EAAO,QAAQ,CAC3C,CAEO,cACLE,EACAgB,EACAC,EACAC,EACA,CAQA,OAPID,GAASC,EAETF,EAAOhB,EAAMiB,CAAK,GAClBD,EAAOhB,EAAMkB,CAAG,GACf,KAAK,QAAQlB,EAAMiB,CAAK,GAAK,KAAK,SAASjB,EAAMkB,CAAG,EAGjDD,GAASD,EAAOhB,EAAMiB,CAAK,GAAOC,GAAOF,EAAOhB,EAAMkB,CAAG,GAAM,EACzE,CAEO,WAAWrB,EAAiBC,EAAmB,CACpD,OAAO,KAAK,UAAUD,EAAMC,CAAK,CACnC,CAEO,eAAeD,EAAiBC,EAAmB,CACxD,OAAO,KAAK,aAAaD,EAAMC,CAAK,CACtC,CAEO,QAAQD,EAAiBC,EAAmB,CACjD,OAAO,KAAK,IAAID,CAAI,CAAC,CAAC,SAAS,IAAM,KAAK,IAAIC,CAAK,CAAC,CAAC,SAAS,CAChE,CACF,E"}
@@ -0,0 +1,3 @@
1
+ export { default as LuxonAdapter } from "./LuxonAdapter";
2
+ export type { LuxonAdapterOptions } from "./LuxonAdapter";
3
+ export { default } from "./LuxonAdapter";
package/dist/index.js ADDED
@@ -0,0 +1,249 @@
1
+ import { DateTime as e, Info as t } from "luxon";
2
+ import { isString as n } from "@weekwise/core";
3
+ // src/LuxonAdapter.ts
4
+ var r = {
5
+ dayNum: "dd",
6
+ weekdayLong: "cccc",
7
+ weekdayShort: "ccc",
8
+ monthLong: "LLLL",
9
+ month: "LLL",
10
+ dateTimeShort: "f",
11
+ dateTime: "F",
12
+ dateTimeLong: "ff",
13
+ date: "D",
14
+ dateLong: "DDD",
15
+ dateShort: "d MMMM",
16
+ time: "tt",
17
+ timeShort: "t",
18
+ timeCompact: "t"
19
+ }, i = class i {
20
+ constructor(e = {}) {
21
+ this.locale = e.locale ?? "en-GB", this.timeZone = e.timeZone, this.weekStartsOn = t.getStartOfWeek({ locale: this.locale }) % 7, this.formatPatterns = {
22
+ ...r,
23
+ ...e.formats
24
+ };
25
+ for (let e = Object.getPrototypeOf(this); e && e !== Object.prototype; e = Object.getPrototypeOf(e)) for (let t of Object.getOwnPropertyNames(e)) {
26
+ let n = Object.getOwnPropertyDescriptor(e, t);
27
+ t !== "constructor" && typeof n?.value == "function" && !Object.prototype.hasOwnProperty.call(this, t) && Object.defineProperty(this, t, {
28
+ value: n.value.bind(this),
29
+ writable: !0,
30
+ configurable: !0
31
+ });
32
+ }
33
+ }
34
+ withLocale(e) {
35
+ return new i({
36
+ locale: e,
37
+ timeZone: this.timeZone,
38
+ formats: this._formatOverrides()
39
+ });
40
+ }
41
+ _formatOverrides() {
42
+ let e = {};
43
+ for (let t of Object.keys(r)) this.formatPatterns[t] !== r[t] && (e[t] = this.formatPatterns[t]);
44
+ return e;
45
+ }
46
+ _resolve(e) {
47
+ return e in this.formatPatterns ? this.formatPatterns[e] : e;
48
+ }
49
+ get _zone() {
50
+ return this.timeZone ?? "default";
51
+ }
52
+ _dt(t = /* @__PURE__ */ new Date()) {
53
+ let r = {
54
+ zone: this._zone,
55
+ locale: this.locale
56
+ };
57
+ return n(t) ? e.fromISO(t, r) : typeof t == "number" ? e.fromMillis(t, r) : e.fromJSDate(t, r);
58
+ }
59
+ _isSame(e, t, n) {
60
+ return this._dt(e).hasSame(this._dt(t), n);
61
+ }
62
+ toMillis(e) {
63
+ return this._dt(e).toMillis();
64
+ }
65
+ fromMillis(e) {
66
+ return new Date(e);
67
+ }
68
+ format(e, t = this.formatPatterns.dateTime) {
69
+ let n = this._dt(e);
70
+ if (!n.isValid) throw RangeError("Invalid time value");
71
+ return n.toFormat(this._resolve(t));
72
+ }
73
+ formatDistanceToNow(e) {
74
+ return this._dt(e).toRelative() ?? "";
75
+ }
76
+ tryFormat(e, t = this.formatPatterns.dateTime) {
77
+ return this.isValid(e) ? this.format(e, t) : null;
78
+ }
79
+ parse(t, n = this.formatPatterns.dateTime) {
80
+ return e.fromFormat(t, this._resolve(n), {
81
+ locale: this.locale,
82
+ zone: this._zone
83
+ }).toJSDate();
84
+ }
85
+ tryParse(e, t = this.formatPatterns.dateTime) {
86
+ let n = this.parse(e, t);
87
+ return Number.isNaN(n.getTime()) ? null : n;
88
+ }
89
+ parseISO(t) {
90
+ return e.fromISO(t, { zone: this._zone }).toJSDate();
91
+ }
92
+ weekDayShortName(t) {
93
+ return this.format(e.fromObject({
94
+ year: 2024,
95
+ month: 1,
96
+ day: 7 + t,
97
+ hour: 12
98
+ }, { zone: this._zone }).toJSDate(), "weekdayShort");
99
+ }
100
+ monthShortName(e) {
101
+ return this._dt(e).toFormat("LLL");
102
+ }
103
+ monthFullName(e) {
104
+ return this._dt(e).toFormat("LLLL");
105
+ }
106
+ getNow(e) {
107
+ return e ? new Date(e) : /* @__PURE__ */ new Date();
108
+ }
109
+ getEndOfMonth(e) {
110
+ return this._dt(e).endOf("month").toJSDate();
111
+ }
112
+ getWeekDay(e) {
113
+ return this._dt(e).weekday % 7;
114
+ }
115
+ getMonthDay(e) {
116
+ return this._dt(e).day;
117
+ }
118
+ getYears(e) {
119
+ return this._dt(e).year;
120
+ }
121
+ getMonths(e) {
122
+ return this._dt(e).month - 1;
123
+ }
124
+ getHours(e) {
125
+ return this._dt(e).hour;
126
+ }
127
+ getMinutes(e) {
128
+ return this._dt(e).minute;
129
+ }
130
+ getSeconds(e) {
131
+ return this._dt(e).second;
132
+ }
133
+ getMilliseconds(e) {
134
+ return this._dt(e).millisecond;
135
+ }
136
+ getToday() {
137
+ return this._dt().startOf("day").toJSDate();
138
+ }
139
+ getStartOfDay(e) {
140
+ return this._dt(e).startOf("day").toJSDate();
141
+ }
142
+ getStartOfMonth(e) {
143
+ return this._dt(e).startOf("month").toJSDate();
144
+ }
145
+ getStartOfWeek(e, t = this.weekStartsOn) {
146
+ let n = this._dt(e).startOf("day");
147
+ return n.minus({ days: (n.weekday % 7 - t + 7) % 7 }).toJSDate();
148
+ }
149
+ getEndOfWeek(e, t = this.weekStartsOn) {
150
+ return this._dt(this.getStartOfWeek(e, t)).plus({ days: 6 }).endOf("day").toJSDate();
151
+ }
152
+ getStartOfYearPeriod(e, t = 0) {
153
+ let n = this._dt(e).startOf("year");
154
+ return t ? n.set({ year: Math.floor(n.year / t) * t }).toJSDate() : n.toJSDate();
155
+ }
156
+ getDifferenceInMinutes(e, t) {
157
+ return Math.trunc(this._dt(e).diff(this._dt(t), "minutes").minutes);
158
+ }
159
+ addYears(e, t) {
160
+ return this._dt(e).plus({ years: t }).toJSDate();
161
+ }
162
+ addMonths(e, t) {
163
+ return this._dt(e).plus({ months: t }).toJSDate();
164
+ }
165
+ addDays(e, t) {
166
+ return this._dt(e).plus({ days: t }).toJSDate();
167
+ }
168
+ addHours(e, t) {
169
+ return this._dt(e).plus({ hours: t }).toJSDate();
170
+ }
171
+ addMinutes(e, t) {
172
+ return this._dt(e).plus({ minutes: t }).toJSDate();
173
+ }
174
+ addSeconds(e, t) {
175
+ return this._dt(e).plus({ seconds: t }).toJSDate();
176
+ }
177
+ setYears(e, t) {
178
+ return this._dt(e).set({ year: t }).toJSDate();
179
+ }
180
+ setMonths(e, t) {
181
+ return this._dt(e).set({ month: t + 1 }).toJSDate();
182
+ }
183
+ setMonthDay(e, t) {
184
+ return this._dt(e).set({ day: t }).toJSDate();
185
+ }
186
+ setHours(e, t) {
187
+ return this._dt(e).set({ hour: t }).toJSDate();
188
+ }
189
+ setMinutes(e, t) {
190
+ return this._dt(e).set({ minute: t }).toJSDate();
191
+ }
192
+ setSeconds(e, t) {
193
+ return this._dt(e).set({ second: t }).toJSDate();
194
+ }
195
+ setMilliseconds(e, t) {
196
+ return this._dt(e).set({ millisecond: t }).toJSDate();
197
+ }
198
+ isBefore(e, t) {
199
+ return this._dt(e) < this._dt(t);
200
+ }
201
+ isAfter(e, t) {
202
+ return this._dt(e) > this._dt(t);
203
+ }
204
+ isValid(e) {
205
+ return this._dt(e).isValid;
206
+ }
207
+ isMatch(t, n = this.formatPatterns.dateTime) {
208
+ return e.fromFormat(t, this._resolve(n), {
209
+ locale: this.locale,
210
+ zone: this._zone
211
+ }).isValid;
212
+ }
213
+ isToday(e) {
214
+ return this._isSame(e, void 0, "day");
215
+ }
216
+ isSameMonth(e, t) {
217
+ return this._isSame(e, t, "month");
218
+ }
219
+ isSameDay(e, t) {
220
+ return this._isSame(e, t, "day");
221
+ }
222
+ isSameYear(e, t) {
223
+ return this._isSame(e, t, "year");
224
+ }
225
+ isSameHour(e, t) {
226
+ return this._isSame(e, t, "hour");
227
+ }
228
+ isSameMinute(e, t) {
229
+ return this._isSame(e, t, "minute");
230
+ }
231
+ isSameSecond(e, t) {
232
+ return this._isSame(e, t, "second");
233
+ }
234
+ isDateInRange(e, t, n, r) {
235
+ return n && r ? t(e, n) || t(e, r) || this.isAfter(e, n) && this.isBefore(e, r) : n && t(e, n) || r && t(e, r) || !1;
236
+ }
237
+ isSameDate(e, t) {
238
+ return this.isSameDay(e, t);
239
+ }
240
+ isSameDateTime(e, t) {
241
+ return this.isSameSecond(e, t);
242
+ }
243
+ isEqual(e, t) {
244
+ return this._dt(e).toMillis() === this._dt(t).toMillis();
245
+ }
246
+ };
247
+ export { i as LuxonAdapter, i as default };
248
+
249
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["DateTime","Info","isString","DEFAULT_FORMATS","LuxonAdapter","options","proto","name","descriptor","locale","overrides","key","formatOrPatternKey","value","left","right","unit","date","millis","dateString","weekStart","day","period","yearStart","count","year","month","hour","minute","second","millisecond","date1","date2","isSame","start","end"],"sources":["../src/LuxonAdapter.ts"],"sourcesContent":["import { DateTime, Info, type DateTimeUnit } from \"luxon\";\n\nimport {\n isString,\n type DateAdapter,\n type DateFormatPattern,\n type DateFormatPatterns,\n type WeekDay,\n} from \"@weekwise/core\";\n\ntype DateInput = Date | number | string;\n\nexport interface LuxonAdapterOptions {\n /**\n * BCP 47 locale, e.g. `\"ru\"`, `\"en-US\"`: month and weekday names, date/time formats and the\n * first day of the week come from the browser's Intl data, so no locale files are imported.\n * The calendar picks its interface language by it too. Defaults to `\"en-GB\"`.\n *\n * @example\n * new LuxonAdapter({ locale: \"ru\" });\n */\n locale?: string;\n /**\n * IANA time zone the calendar shows, e.g. `\"America/New_York\"`: days start at its midnight\n * and times are its wall-clock times. Dates stay `Date`s (moments in time). Defaults to the\n * runtime's zone.\n */\n timeZone?: string;\n /** Overrides of the built-in patterns, in Luxon tokens: `{ timeShort: \"h:mm a\" }`. */\n formats?: Partial<DateFormatPatterns>;\n}\n\n/**\n * Built-in patterns. `D`/`DDD` (date), `t`/`tt` (time) and `f`/`F`/`ff` (date and time) are\n * Luxon macro tokens, so every locale gets its own order, separators and 12/24-hour clock.\n */\nconst DEFAULT_FORMATS: DateFormatPatterns = {\n dayNum: \"dd\",\n weekdayLong: \"cccc\",\n weekdayShort: \"ccc\",\n monthLong: \"LLLL\",\n month: \"LLL\",\n dateTimeShort: \"f\",\n dateTime: \"F\",\n dateTimeLong: \"ff\",\n date: \"D\",\n dateLong: \"DDD\",\n dateShort: \"d MMMM\",\n time: \"tt\",\n timeShort: \"t\",\n timeCompact: \"t\",\n};\n\n/**\n * {@link DateAdapter} implementation backed by Luxon.\n */\nexport default class LuxonAdapter implements DateAdapter {\n readonly locale: string;\n readonly weekStartsOn: WeekDay;\n readonly timeZone?: string;\n readonly formatPatterns: DateFormatPatterns;\n\n constructor(options: LuxonAdapterOptions = {}) {\n this.locale = options.locale ?? \"en-GB\";\n this.timeZone = options.timeZone;\n // Luxon numbers weekdays 1 (Monday) … 7 (Sunday)\n this.weekStartsOn = (Info.getStartOfWeek({ locale: this.locale }) % 7) as WeekDay;\n this.formatPatterns = { ...DEFAULT_FORMATS, ...options.formats };\n\n // The calendar destructures adapter methods (`const { format } = adapter`)\n for (let proto = Object.getPrototypeOf(this); proto && proto !== Object.prototype; proto = Object.getPrototypeOf(proto)) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (name !== \"constructor\" && typeof descriptor?.value === \"function\" && !Object.prototype.hasOwnProperty.call(this, name)) {\n Object.defineProperty(this, name, { value: descriptor.value.bind(this), writable: true, configurable: true });\n }\n }\n }\n }\n\n /** Same settings with another locale, e.g. when the user switches the interface language. */\n public withLocale(locale: string): LuxonAdapter {\n return new LuxonAdapter({ locale, timeZone: this.timeZone, formats: this._formatOverrides() });\n }\n\n private _formatOverrides(): Partial<DateFormatPatterns> {\n const overrides: Partial<DateFormatPatterns> = {};\n for (const key of Object.keys(DEFAULT_FORMATS) as DateFormatPattern[]) {\n if (this.formatPatterns[key] !== DEFAULT_FORMATS[key]) overrides[key] = this.formatPatterns[key];\n }\n return overrides;\n }\n\n private _resolve(formatOrPatternKey: string): string {\n return formatOrPatternKey in this.formatPatterns\n ? this.formatPatterns[formatOrPatternKey as DateFormatPattern]\n : formatOrPatternKey;\n }\n\n /** Luxon's zone option: the adapter's zone, else the runtime's. */\n private get _zone() {\n return this.timeZone ?? \"default\";\n }\n\n /**\n * A Luxon DateTime in the adapter's locale and time zone. Strings are read as ISO 8601,\n * in that zone when they have no offset.\n */\n private _dt(value: DateInput = new Date()): DateTime {\n const options = { zone: this._zone, locale: this.locale };\n return isString(value)\n ? DateTime.fromISO(value, options)\n : typeof value === \"number\"\n ? DateTime.fromMillis(value, options)\n : DateTime.fromJSDate(value, options);\n }\n\n private _isSame(left: DateInput, right: DateInput | undefined, unit: DateTimeUnit): boolean {\n return this._dt(left).hasSame(this._dt(right), unit);\n }\n\n public toMillis(date: DateInput): number {\n return this._dt(date).toMillis();\n }\n\n public fromMillis(millis: number): Date {\n return new Date(millis);\n }\n\n public format(\n date: DateInput,\n formatOrPatternKey: DateFormatPattern | (string & {}) = this.formatPatterns.dateTime\n ) {\n const value = this._dt(date);\n if (!value.isValid) throw new RangeError(\"Invalid time value\");\n return value.toFormat(this._resolve(formatOrPatternKey));\n }\n\n public formatDistanceToNow(date: DateInput) {\n return this._dt(date).toRelative() ?? \"\";\n }\n\n public tryFormat(\n date: DateInput,\n formatOrPatternKey: DateFormatPattern | (string & {}) = this.formatPatterns.dateTime\n ) {\n if (!this.isValid(date)) return null;\n return this.format(date, formatOrPatternKey);\n }\n\n public parse(\n dateString: string,\n formatOrPatternKey: DateFormatPattern | (string & {}) = this.formatPatterns.dateTime\n ): Date {\n return DateTime.fromFormat(dateString, this._resolve(formatOrPatternKey), {\n locale: this.locale,\n zone: this._zone,\n }).toJSDate();\n }\n\n public tryParse(\n dateString: string,\n formatOrPatternKey: DateFormatPattern | (string & {}) = this.formatPatterns.dateTime\n ) {\n const date = this.parse(dateString, formatOrPatternKey);\n return Number.isNaN(date.getTime()) ? null : date;\n }\n\n public parseISO(date: string): Date {\n return DateTime.fromISO(date, { zone: this._zone }).toJSDate();\n }\n\n public weekDayShortName(value: number): string {\n // 7 January 2024 is a Sunday: built in the adapter's zone, where a local midnight can be the day before\n return this.format(DateTime.fromObject({ year: 2024, month: 1, day: 7 + value, hour: 12 }, { zone: this._zone }).toJSDate(), \"weekdayShort\");\n }\n\n public monthShortName(value: DateInput): string {\n return this._dt(value).toFormat(\"LLL\");\n }\n\n public monthFullName(value: DateInput): string {\n return this._dt(value).toFormat(\"LLLL\");\n }\n\n // Get\n public getNow(date?: number | string): Date {\n return date ? new Date(date) : new Date();\n }\n\n public getEndOfMonth(date?: DateInput): Date {\n return this._dt(date).endOf(\"month\").toJSDate();\n }\n\n public getWeekDay(date?: DateInput) {\n return this._dt(date).weekday % 7;\n }\n\n public getMonthDay(date?: DateInput): number {\n return this._dt(date).day;\n }\n\n public getYears(date?: DateInput): number {\n return this._dt(date).year;\n }\n\n public getMonths(date?: DateInput) {\n // Luxon months are 1-based\n return this._dt(date).month - 1;\n }\n\n public getHours(date?: DateInput): number {\n return this._dt(date).hour;\n }\n\n public getMinutes(date?: DateInput): number {\n return this._dt(date).minute;\n }\n\n public getSeconds(date?: DateInput): number {\n return this._dt(date).second;\n }\n\n public getMilliseconds(date?: DateInput): number {\n return this._dt(date).millisecond;\n }\n\n public getToday(): Date {\n return this._dt().startOf(\"day\").toJSDate();\n }\n\n public getStartOfDay(date?: DateInput): Date {\n return this._dt(date).startOf(\"day\").toJSDate();\n }\n\n public getStartOfMonth(date?: DateInput): Date {\n return this._dt(date).startOf(\"month\").toJSDate();\n }\n\n public getStartOfWeek(date?: DateInput, weekStart: WeekDay = this.weekStartsOn): Date {\n const day = this._dt(date).startOf(\"day\");\n return day.minus({ days: ((day.weekday % 7) - weekStart + 7) % 7 }).toJSDate();\n }\n\n public getEndOfWeek(date?: DateInput, weekStart: WeekDay = this.weekStartsOn): Date {\n return this._dt(this.getStartOfWeek(date, weekStart))\n .plus({ days: 6 })\n .endOf(\"day\")\n .toJSDate();\n }\n\n public getStartOfYearPeriod(date?: DateInput, period = 0) {\n const yearStart = this._dt(date).startOf(\"year\");\n if (period) {\n return yearStart.set({ year: Math.floor(yearStart.year / period) * period }).toJSDate();\n }\n\n return yearStart.toJSDate();\n }\n\n public getDifferenceInMinutes(left: DateInput, right?: DateInput): number {\n return Math.trunc(this._dt(left).diff(this._dt(right), \"minutes\").minutes);\n }\n\n public addYears(date: DateInput, count: number): Date {\n return this._dt(date).plus({ years: count }).toJSDate();\n }\n\n public addMonths(date: DateInput, count: number): Date {\n return this._dt(date).plus({ months: count }).toJSDate();\n }\n\n public addDays(date: DateInput, count: number): Date {\n return this._dt(date).plus({ days: count }).toJSDate();\n }\n\n public addHours(date: DateInput, count: number): Date {\n return this._dt(date).plus({ hours: count }).toJSDate();\n }\n\n public addMinutes(date: DateInput, count: number): Date {\n return this._dt(date).plus({ minutes: count }).toJSDate();\n }\n\n public addSeconds(date: DateInput, count: number): Date {\n return this._dt(date).plus({ seconds: count }).toJSDate();\n }\n\n public setYears(date: DateInput, year: number): Date {\n return this._dt(date).set({ year }).toJSDate();\n }\n\n public setMonths(date: DateInput, month: number): Date {\n return this._dt(date).set({ month: month + 1 }).toJSDate();\n }\n\n public setMonthDay(date: DateInput, day: number): Date {\n return this._dt(date).set({ day }).toJSDate();\n }\n\n public setHours(date: DateInput, hour: number): Date {\n return this._dt(date).set({ hour }).toJSDate();\n }\n\n public setMinutes(date: DateInput, minute: number): Date {\n return this._dt(date).set({ minute }).toJSDate();\n }\n\n public setSeconds(date: DateInput, second: number): Date {\n return this._dt(date).set({ second }).toJSDate();\n }\n\n public setMilliseconds(date: DateInput, millisecond: number): Date {\n return this._dt(date).set({ millisecond }).toJSDate();\n }\n\n public isBefore(date1: DateInput, date2?: DateInput): boolean {\n return this._dt(date1) < this._dt(date2);\n }\n\n public isAfter(date1: DateInput, date2?: DateInput): boolean {\n return this._dt(date1) > this._dt(date2);\n }\n\n public isValid(date: DateInput): boolean {\n return this._dt(date).isValid;\n }\n\n public isMatch(\n date: string,\n formatOrPatternKey: DateFormatPattern | (string & {}) = this.formatPatterns.dateTime\n ): boolean {\n return DateTime.fromFormat(date, this._resolve(formatOrPatternKey), { locale: this.locale, zone: this._zone })\n .isValid;\n }\n\n public isToday(date: DateInput): boolean {\n return this._isSame(date, undefined, \"day\");\n }\n\n public isSameMonth(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"month\");\n }\n\n public isSameDay(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"day\");\n }\n\n public isSameYear(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"year\");\n }\n\n public isSameHour(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"hour\");\n }\n\n public isSameMinute(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"minute\");\n }\n\n public isSameSecond(left: DateInput, right?: DateInput): boolean {\n return this._isSame(left, right, \"second\");\n }\n\n public isDateInRange(\n date: DateInput,\n isSame: (left: DateInput, right: DateInput) => boolean,\n start?: DateInput,\n end?: DateInput\n ) {\n if (start && end) {\n return (\n isSame(date, start) ||\n isSame(date, end) ||\n (this.isAfter(date, start) && this.isBefore(date, end))\n );\n }\n return (start && isSame(date, start)) || (end && isSame(date, end)) || false;\n }\n\n public isSameDate(left: DateInput, right?: DateInput) {\n return this.isSameDay(left, right);\n }\n\n public isSameDateTime(left: DateInput, right?: DateInput) {\n return this.isSameSecond(left, right);\n }\n\n public isEqual(left: DateInput, right?: DateInput) {\n return this._dt(left).toMillis() === this._dt(right).toMillis();\n }\n}\n"],"mappings":";;;AAoCA,IAAMG,IAAsC;CAC1C,QAAQ;CACR,aAAa;CACb,cAAc;CACd,WAAW;CACX,OAAO;CACP,eAAe;CACf,UAAU;CACV,cAAc;CACd,MAAM;CACN,UAAU;CACV,WAAW;CACX,MAAM;CACN,WAAW;CACX,aAAa;AACf,GAKqBC,IAArB,MAAqBA,EAAoC;CAMvD,YAAYC,IAA+B,CAAC,GAAG;EAC7C,KAAK,SAASA,EAAQ,UAAU,SAChC,KAAK,WAAWA,EAAQ,UAExB,KAAK,eAAgBJ,EAAK,eAAe,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,GACpE,KAAK,iBAAiB;GAAE,GAAGE;GAAiB,GAAGE,EAAQ;EAAQ;EAG/D,KAAK,IAAIC,IAAQ,OAAO,eAAe,IAAI,GAAGA,KAASA,MAAU,OAAO,WAAWA,IAAQ,OAAO,eAAeA,CAAK,GACpH,KAAK,IAAMC,KAAQ,OAAO,oBAAoBD,CAAK,GAAG;GACpD,IAAME,IAAa,OAAO,yBAAyBF,GAAOC,CAAI;GAC1DA,MAAS,iBAAiB,OAAOC,GAAY,SAAU,cAAc,CAAC,OAAO,UAAU,eAAe,KAAK,MAAMD,CAAI,KACvH,OAAO,eAAe,MAAMA,GAAM;IAAE,OAAOC,EAAW,MAAM,KAAK,IAAI;IAAG,UAAU;IAAM,cAAc;GAAK,CAAC;EAEhH;CAEJ;CAGO,WAAWC,GAA8B;EAC9C,OAAO,IAAIL,EAAa;GAAEK;GAAQ,UAAU,KAAK;GAAU,SAAS,KAAK,iBAAiB;EAAE,CAAC;CAC/F;CAEQ,mBAAgD;EACtD,IAAMC,IAAyC,CAAC;EAChD,KAAK,IAAMC,KAAO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GAAMC,GAAO,MAAM;CACzC;CAEO,WAAWD,GAAiBC,GAA4B;EAC7D,OAAO,KAAK,QAAQD,GAAMC,GAAO,MAAM;CACzC;CAEO,aAAaD,GAAiBC,GAA4B;EAC/D,OAAO,KAAK,QAAQD,GAAMC,GAAO,QAAQ;CAC3C;CAEO,aAAaD,GAAiBC,GAA4B;EAC/D,OAAO,KAAK,QAAQD,GAAMC,GAAO,QAAQ;CAC3C;CAEO,cACLE,GACAgB,GACAC,GACAC,GACA;EAQA,OAPID,KAASC,IAETF,EAAOhB,GAAMiB,CAAK,KAClBD,EAAOhB,GAAMkB,CAAG,KACf,KAAK,QAAQlB,GAAMiB,CAAK,KAAK,KAAK,SAASjB,GAAMkB,CAAG,IAGjDD,KAASD,EAAOhB,GAAMiB,CAAK,KAAOC,KAAOF,EAAOhB,GAAMkB,CAAG,KAAM;CACzE;CAEO,WAAWrB,GAAiBC,GAAmB;EACpD,OAAO,KAAK,UAAUD,GAAMC,CAAK;CACnC;CAEO,eAAeD,GAAiBC,GAAmB;EACxD,OAAO,KAAK,aAAaD,GAAMC,CAAK;CACtC;CAEO,QAAQD,GAAiBC,GAAmB;EACjD,OAAO,KAAK,IAAID,CAAI,CAAC,CAAC,SAAS,MAAM,KAAK,IAAIC,CAAK,CAAC,CAAC,SAAS;CAChE;AACF"}
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@weekwise/adapter-luxon",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Luxon adapter for the weekwise calendar.",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "sideEffects": false,
22
+ "keywords": [
23
+ "calendar",
24
+ "weekwise",
25
+ "luxon",
26
+ "date-adapter"
27
+ ],
28
+ "license": "MIT",
29
+ "author": "ivp-dev",
30
+ "homepage": "https://weekwise.dev/guides/date-adapters/",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/ivp-dev/weekwise.git",
34
+ "directory": "packages/adapters/luxon"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/ivp-dev/weekwise/issues"
38
+ },
39
+ "dependencies": {
40
+ "@weekwise/core": "^0.1.0"
41
+ },
42
+ "peerDependencies": {
43
+ "luxon": "^3.4.0"
44
+ },
45
+ "devDependencies": {
46
+ "luxon": "^3.7.2",
47
+ "@types/luxon": "^3.7.6"
48
+ },
49
+ "scripts": {
50
+ "build": "vite build && tsc -p tsconfig.build.json",
51
+ "typecheck": "tsc --noEmit",
52
+ "test": "vitest run"
53
+ }
6
54
  }