@fullcalendar/luxon3 6.1.8

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.md ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Adam Shaw
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+
2
+ # FullCalendar Luxon 2 Plugin
3
+
4
+ Enhanced date formatting, conversion, and [named time zone](https://fullcalendar.io/docs/timeZone#named-time-zones) functionality with [Luxon](https://moment.github.io/luxon/) 2
5
+
6
+ ## Installation
7
+
8
+ First, ensure Luxon is installed:
9
+
10
+ ```sh
11
+ npm install luxon@2
12
+ ```
13
+
14
+ Then, install the FullCalendar core package, the Luxon plugin, and any other plugins (like [daygrid](https://fullcalendar.io/docs/month-view)):
15
+
16
+ ```sh
17
+ npm install @fullcalendar/core @fullcalendar/luxon2 @fullcalendar/daygrid
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Instantiate a Calendar with the necessary plugin:
23
+
24
+ ```js
25
+ import { Calendar } from '@fullcalendar/core'
26
+ import luxon2Plugin from '@fullcalendar/luxon2'
27
+ import dayGridPlugin from '@fullcalendar/daygrid'
28
+
29
+ const calendarEl = document.getElementById('calendar')
30
+ const calendar = new Calendar(calendarEl, {
31
+ plugins: [
32
+ luxon2Plugin,
33
+ dayGridPlugin
34
+ ],
35
+ initialView: 'dayGridMonth',
36
+ titleFormat: 'LLLL d, yyyy', // use Luxon format strings
37
+ timeZone: 'America/New_York' // enhance named time zones
38
+ })
39
+
40
+ calendar.render()
41
+ ```
package/index.cjs ADDED
@@ -0,0 +1,123 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var index_cjs = require('@fullcalendar/core/index.cjs');
6
+ var luxon = require('luxon');
7
+ var internal_cjs = require('@fullcalendar/core/internal.cjs');
8
+
9
+ function toLuxonDateTime(date, calendar) {
10
+ if (!(calendar instanceof internal_cjs.CalendarImpl)) {
11
+ throw new Error('must supply a CalendarApi instance');
12
+ }
13
+ let { dateEnv } = calendar.getCurrentData();
14
+ return luxon.DateTime.fromJSDate(date, {
15
+ zone: dateEnv.timeZone,
16
+ locale: dateEnv.locale.codes[0],
17
+ });
18
+ }
19
+ function toLuxonDuration(duration, calendar) {
20
+ if (!(calendar instanceof internal_cjs.CalendarImpl)) {
21
+ throw new Error('must supply a CalendarApi instance');
22
+ }
23
+ let { dateEnv } = calendar.getCurrentData();
24
+ return luxon.Duration.fromObject(duration, {
25
+ locale: dateEnv.locale.codes[0],
26
+ });
27
+ }
28
+ // Internal Utils
29
+ function luxonToArray(datetime) {
30
+ return [
31
+ datetime.year,
32
+ datetime.month - 1,
33
+ datetime.day,
34
+ datetime.hour,
35
+ datetime.minute,
36
+ datetime.second,
37
+ datetime.millisecond,
38
+ ];
39
+ }
40
+ function arrayToLuxon(arr, timeZone, locale) {
41
+ return luxon.DateTime.fromObject({
42
+ year: arr[0],
43
+ month: arr[1] + 1,
44
+ day: arr[2],
45
+ hour: arr[3],
46
+ minute: arr[4],
47
+ second: arr[5],
48
+ millisecond: arr[6],
49
+ }, {
50
+ locale,
51
+ zone: timeZone,
52
+ });
53
+ }
54
+
55
+ class LuxonNamedTimeZone extends internal_cjs.NamedTimeZoneImpl {
56
+ offsetForArray(a) {
57
+ return arrayToLuxon(a, this.timeZoneName).offset;
58
+ }
59
+ timestampToArray(ms) {
60
+ return luxonToArray(luxon.DateTime.fromMillis(ms, {
61
+ zone: this.timeZoneName,
62
+ }));
63
+ }
64
+ }
65
+
66
+ function formatWithCmdStr(cmdStr, arg) {
67
+ let cmd = parseCmdStr(cmdStr);
68
+ if (arg.end) {
69
+ let start = arrayToLuxon(arg.start.array, arg.timeZone, arg.localeCodes[0]);
70
+ let end = arrayToLuxon(arg.end.array, arg.timeZone, arg.localeCodes[0]);
71
+ return formatRange(cmd, start.toFormat.bind(start), end.toFormat.bind(end), arg.defaultSeparator);
72
+ }
73
+ return arrayToLuxon(arg.date.array, arg.timeZone, arg.localeCodes[0]).toFormat(cmd.whole);
74
+ }
75
+ function parseCmdStr(cmdStr) {
76
+ let parts = cmdStr.match(/^(.*?)\{(.*)\}(.*)$/); // TODO: lookbehinds for escape characters
77
+ if (parts) {
78
+ let middle = parseCmdStr(parts[2]);
79
+ return {
80
+ head: parts[1],
81
+ middle,
82
+ tail: parts[3],
83
+ whole: parts[1] + middle.whole + parts[3],
84
+ };
85
+ }
86
+ return {
87
+ head: null,
88
+ middle: null,
89
+ tail: null,
90
+ whole: cmdStr,
91
+ };
92
+ }
93
+ function formatRange(cmd, formatStart, formatEnd, separator) {
94
+ if (cmd.middle) {
95
+ let startHead = formatStart(cmd.head);
96
+ let startMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator);
97
+ let startTail = formatStart(cmd.tail);
98
+ let endHead = formatEnd(cmd.head);
99
+ let endMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator);
100
+ let endTail = formatEnd(cmd.tail);
101
+ if (startHead === endHead && startTail === endTail) {
102
+ return startHead +
103
+ (startMiddle === endMiddle ? startMiddle : startMiddle + separator + endMiddle) +
104
+ startTail;
105
+ }
106
+ }
107
+ let startWhole = formatStart(cmd.whole);
108
+ let endWhole = formatEnd(cmd.whole);
109
+ if (startWhole === endWhole) {
110
+ return startWhole;
111
+ }
112
+ return startWhole + separator + endWhole;
113
+ }
114
+
115
+ var index = index_cjs.createPlugin({
116
+ name: '@fullcalendar/luxon3',
117
+ cmdFormatter: formatWithCmdStr,
118
+ namedTimeZonedImpl: LuxonNamedTimeZone,
119
+ });
120
+
121
+ exports["default"] = index;
122
+ exports.toLuxonDateTime = toLuxonDateTime;
123
+ exports.toLuxonDuration = toLuxonDuration;
package/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { CalendarApi, Duration, PluginDef } from '@fullcalendar/core';
2
+ import { DateTime, Duration as Duration$1 } from 'luxon';
3
+
4
+ declare function toLuxonDateTime(date: Date, calendar: CalendarApi): DateTime;
5
+ declare function toLuxonDuration(duration: Duration, calendar: CalendarApi): Duration$1;
6
+
7
+ declare const _default: PluginDef;
8
+ //# sourceMappingURL=index.d.ts.map
9
+
10
+ export { _default as default, toLuxonDateTime, toLuxonDuration };
@@ -0,0 +1,131 @@
1
+ /*!
2
+ FullCalendar Luxon 3 Plugin v6.1.8
3
+ Docs & License: https://fullcalendar.io/docs/luxon
4
+ (c) 2023 Adam Shaw
5
+ */
6
+ FullCalendar.Luxon3 = (function (exports, core, luxon, internal) {
7
+ 'use strict';
8
+
9
+ function toLuxonDateTime(date, calendar) {
10
+ if (!(calendar instanceof internal.CalendarImpl)) {
11
+ throw new Error('must supply a CalendarApi instance');
12
+ }
13
+ let { dateEnv } = calendar.getCurrentData();
14
+ return luxon.DateTime.fromJSDate(date, {
15
+ zone: dateEnv.timeZone,
16
+ locale: dateEnv.locale.codes[0],
17
+ });
18
+ }
19
+ function toLuxonDuration(duration, calendar) {
20
+ if (!(calendar instanceof internal.CalendarImpl)) {
21
+ throw new Error('must supply a CalendarApi instance');
22
+ }
23
+ let { dateEnv } = calendar.getCurrentData();
24
+ return luxon.Duration.fromObject(duration, {
25
+ locale: dateEnv.locale.codes[0],
26
+ });
27
+ }
28
+ // Internal Utils
29
+ function luxonToArray(datetime) {
30
+ return [
31
+ datetime.year,
32
+ datetime.month - 1,
33
+ datetime.day,
34
+ datetime.hour,
35
+ datetime.minute,
36
+ datetime.second,
37
+ datetime.millisecond,
38
+ ];
39
+ }
40
+ function arrayToLuxon(arr, timeZone, locale) {
41
+ return luxon.DateTime.fromObject({
42
+ year: arr[0],
43
+ month: arr[1] + 1,
44
+ day: arr[2],
45
+ hour: arr[3],
46
+ minute: arr[4],
47
+ second: arr[5],
48
+ millisecond: arr[6],
49
+ }, {
50
+ locale,
51
+ zone: timeZone,
52
+ });
53
+ }
54
+
55
+ class LuxonNamedTimeZone extends internal.NamedTimeZoneImpl {
56
+ offsetForArray(a) {
57
+ return arrayToLuxon(a, this.timeZoneName).offset;
58
+ }
59
+ timestampToArray(ms) {
60
+ return luxonToArray(luxon.DateTime.fromMillis(ms, {
61
+ zone: this.timeZoneName,
62
+ }));
63
+ }
64
+ }
65
+
66
+ function formatWithCmdStr(cmdStr, arg) {
67
+ let cmd = parseCmdStr(cmdStr);
68
+ if (arg.end) {
69
+ let start = arrayToLuxon(arg.start.array, arg.timeZone, arg.localeCodes[0]);
70
+ let end = arrayToLuxon(arg.end.array, arg.timeZone, arg.localeCodes[0]);
71
+ return formatRange(cmd, start.toFormat.bind(start), end.toFormat.bind(end), arg.defaultSeparator);
72
+ }
73
+ return arrayToLuxon(arg.date.array, arg.timeZone, arg.localeCodes[0]).toFormat(cmd.whole);
74
+ }
75
+ function parseCmdStr(cmdStr) {
76
+ let parts = cmdStr.match(/^(.*?)\{(.*)\}(.*)$/); // TODO: lookbehinds for escape characters
77
+ if (parts) {
78
+ let middle = parseCmdStr(parts[2]);
79
+ return {
80
+ head: parts[1],
81
+ middle,
82
+ tail: parts[3],
83
+ whole: parts[1] + middle.whole + parts[3],
84
+ };
85
+ }
86
+ return {
87
+ head: null,
88
+ middle: null,
89
+ tail: null,
90
+ whole: cmdStr,
91
+ };
92
+ }
93
+ function formatRange(cmd, formatStart, formatEnd, separator) {
94
+ if (cmd.middle) {
95
+ let startHead = formatStart(cmd.head);
96
+ let startMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator);
97
+ let startTail = formatStart(cmd.tail);
98
+ let endHead = formatEnd(cmd.head);
99
+ let endMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator);
100
+ let endTail = formatEnd(cmd.tail);
101
+ if (startHead === endHead && startTail === endTail) {
102
+ return startHead +
103
+ (startMiddle === endMiddle ? startMiddle : startMiddle + separator + endMiddle) +
104
+ startTail;
105
+ }
106
+ }
107
+ let startWhole = formatStart(cmd.whole);
108
+ let endWhole = formatEnd(cmd.whole);
109
+ if (startWhole === endWhole) {
110
+ return startWhole;
111
+ }
112
+ return startWhole + separator + endWhole;
113
+ }
114
+
115
+ var plugin = core.createPlugin({
116
+ name: '@fullcalendar/luxon3',
117
+ cmdFormatter: formatWithCmdStr,
118
+ namedTimeZonedImpl: LuxonNamedTimeZone,
119
+ });
120
+
121
+ core.globalPlugins.push(plugin);
122
+
123
+ exports["default"] = plugin;
124
+ exports.toLuxonDateTime = toLuxonDateTime;
125
+ exports.toLuxonDuration = toLuxonDuration;
126
+
127
+ Object.defineProperty(exports, '__esModule', { value: true });
128
+
129
+ return exports;
130
+
131
+ })({}, FullCalendar, luxon, FullCalendar.Internal);
@@ -0,0 +1,6 @@
1
+ /*!
2
+ FullCalendar Luxon 3 Plugin v6.1.8
3
+ Docs & License: https://fullcalendar.io/docs/luxon
4
+ (c) 2023 Adam Shaw
5
+ */
6
+ FullCalendar.Luxon3=function(e,t,n,a){"use strict";function l(e,t,a){return n.DateTime.fromObject({year:e[0],month:e[1]+1,day:e[2],hour:e[3],minute:e[4],second:e[5],millisecond:e[6]},{locale:a,zone:t})}class r extends a.NamedTimeZoneImpl{offsetForArray(e){return l(e,this.timeZoneName).offset}timestampToArray(e){return[(t=n.DateTime.fromMillis(e,{zone:this.timeZoneName})).year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond];var t}}var o=t.createPlugin({name:"@fullcalendar/luxon3",cmdFormatter:function(e,t){let n=function e(t){let n=t.match(/^(.*?)\{(.*)\}(.*)$/);if(n){let t=e(n[2]);return{head:n[1],middle:t,tail:n[3],whole:n[1]+t.whole+n[3]}}return{head:null,middle:null,tail:null,whole:t}}(e);if(t.end){let e=l(t.start.array,t.timeZone,t.localeCodes[0]),a=l(t.end.array,t.timeZone,t.localeCodes[0]);return function e(t,n,a,l){if(t.middle){let r=n(t.head),o=e(t.middle,n,a,l),i=n(t.tail),u=a(t.head),d=e(t.middle,n,a,l),m=a(t.tail);if(r===u&&i===m)return r+(o===d?o:o+l+d)+i}let r=n(t.whole),o=a(t.whole);if(r===o)return r;return r+l+o}(n,e.toFormat.bind(e),a.toFormat.bind(a),t.defaultSeparator)}return l(t.date.array,t.timeZone,t.localeCodes[0]).toFormat(n.whole)},namedTimeZonedImpl:r});return t.globalPlugins.push(o),e.default=o,e.toLuxonDateTime=function(e,t){if(!(t instanceof a.CalendarImpl))throw new Error("must supply a CalendarApi instance");let{dateEnv:l}=t.getCurrentData();return n.DateTime.fromJSDate(e,{zone:l.timeZone,locale:l.locale.codes[0]})},e.toLuxonDuration=function(e,t){if(!(t instanceof a.CalendarImpl))throw new Error("must supply a CalendarApi instance");let{dateEnv:l}=t.getCurrentData();return n.Duration.fromObject(e,{locale:l.locale.codes[0]})},Object.defineProperty(e,"__esModule",{value:!0}),e}({},FullCalendar,luxon,FullCalendar.Internal);
package/index.js ADDED
@@ -0,0 +1,117 @@
1
+ import { createPlugin } from '@fullcalendar/core/index.js';
2
+ import { DateTime, Duration } from 'luxon';
3
+ import { CalendarImpl, NamedTimeZoneImpl } from '@fullcalendar/core/internal.js';
4
+
5
+ function toLuxonDateTime(date, calendar) {
6
+ if (!(calendar instanceof CalendarImpl)) {
7
+ throw new Error('must supply a CalendarApi instance');
8
+ }
9
+ let { dateEnv } = calendar.getCurrentData();
10
+ return DateTime.fromJSDate(date, {
11
+ zone: dateEnv.timeZone,
12
+ locale: dateEnv.locale.codes[0],
13
+ });
14
+ }
15
+ function toLuxonDuration(duration, calendar) {
16
+ if (!(calendar instanceof CalendarImpl)) {
17
+ throw new Error('must supply a CalendarApi instance');
18
+ }
19
+ let { dateEnv } = calendar.getCurrentData();
20
+ return Duration.fromObject(duration, {
21
+ locale: dateEnv.locale.codes[0],
22
+ });
23
+ }
24
+ // Internal Utils
25
+ function luxonToArray(datetime) {
26
+ return [
27
+ datetime.year,
28
+ datetime.month - 1,
29
+ datetime.day,
30
+ datetime.hour,
31
+ datetime.minute,
32
+ datetime.second,
33
+ datetime.millisecond,
34
+ ];
35
+ }
36
+ function arrayToLuxon(arr, timeZone, locale) {
37
+ return DateTime.fromObject({
38
+ year: arr[0],
39
+ month: arr[1] + 1,
40
+ day: arr[2],
41
+ hour: arr[3],
42
+ minute: arr[4],
43
+ second: arr[5],
44
+ millisecond: arr[6],
45
+ }, {
46
+ locale,
47
+ zone: timeZone,
48
+ });
49
+ }
50
+
51
+ class LuxonNamedTimeZone extends NamedTimeZoneImpl {
52
+ offsetForArray(a) {
53
+ return arrayToLuxon(a, this.timeZoneName).offset;
54
+ }
55
+ timestampToArray(ms) {
56
+ return luxonToArray(DateTime.fromMillis(ms, {
57
+ zone: this.timeZoneName,
58
+ }));
59
+ }
60
+ }
61
+
62
+ function formatWithCmdStr(cmdStr, arg) {
63
+ let cmd = parseCmdStr(cmdStr);
64
+ if (arg.end) {
65
+ let start = arrayToLuxon(arg.start.array, arg.timeZone, arg.localeCodes[0]);
66
+ let end = arrayToLuxon(arg.end.array, arg.timeZone, arg.localeCodes[0]);
67
+ return formatRange(cmd, start.toFormat.bind(start), end.toFormat.bind(end), arg.defaultSeparator);
68
+ }
69
+ return arrayToLuxon(arg.date.array, arg.timeZone, arg.localeCodes[0]).toFormat(cmd.whole);
70
+ }
71
+ function parseCmdStr(cmdStr) {
72
+ let parts = cmdStr.match(/^(.*?)\{(.*)\}(.*)$/); // TODO: lookbehinds for escape characters
73
+ if (parts) {
74
+ let middle = parseCmdStr(parts[2]);
75
+ return {
76
+ head: parts[1],
77
+ middle,
78
+ tail: parts[3],
79
+ whole: parts[1] + middle.whole + parts[3],
80
+ };
81
+ }
82
+ return {
83
+ head: null,
84
+ middle: null,
85
+ tail: null,
86
+ whole: cmdStr,
87
+ };
88
+ }
89
+ function formatRange(cmd, formatStart, formatEnd, separator) {
90
+ if (cmd.middle) {
91
+ let startHead = formatStart(cmd.head);
92
+ let startMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator);
93
+ let startTail = formatStart(cmd.tail);
94
+ let endHead = formatEnd(cmd.head);
95
+ let endMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator);
96
+ let endTail = formatEnd(cmd.tail);
97
+ if (startHead === endHead && startTail === endTail) {
98
+ return startHead +
99
+ (startMiddle === endMiddle ? startMiddle : startMiddle + separator + endMiddle) +
100
+ startTail;
101
+ }
102
+ }
103
+ let startWhole = formatStart(cmd.whole);
104
+ let endWhole = formatEnd(cmd.whole);
105
+ if (startWhole === endWhole) {
106
+ return startWhole;
107
+ }
108
+ return startWhole + separator + endWhole;
109
+ }
110
+
111
+ var index = createPlugin({
112
+ name: '@fullcalendar/luxon3',
113
+ cmdFormatter: formatWithCmdStr,
114
+ namedTimeZonedImpl: LuxonNamedTimeZone,
115
+ });
116
+
117
+ export { index as default, toLuxonDateTime, toLuxonDuration };
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@fullcalendar/luxon3",
3
+ "version": "6.1.8",
4
+ "title": "FullCalendar Luxon 3 Plugin",
5
+ "description": "Enhanced date formatting, conversion, and named time zone functionality with Luxon 3",
6
+ "keywords": [
7
+ "calendar",
8
+ "event",
9
+ "full-sized",
10
+ "fullcalendar",
11
+ "luxon",
12
+ "luxon3",
13
+ "timezone"
14
+ ],
15
+ "homepage": "https://fullcalendar.io/docs/luxon",
16
+ "peerDependencies": {
17
+ "@fullcalendar/core": "~6.1.8",
18
+ "luxon": "^3.0.0"
19
+ },
20
+ "type": "module",
21
+ "bugs": "https://fullcalendar.io/reporting-bugs",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/fullcalendar/fullcalendar.git",
25
+ "directory": "packages/luxon3"
26
+ },
27
+ "license": "MIT",
28
+ "author": {
29
+ "name": "Adam Shaw",
30
+ "email": "arshaw@arshaw.com",
31
+ "url": "http://arshaw.com/"
32
+ },
33
+ "copyright": "2023 Adam Shaw",
34
+ "types": "./index.d.ts",
35
+ "main": "./index.cjs",
36
+ "module": "./index.js",
37
+ "unpkg": "./index.global.min.js",
38
+ "jsdelivr": "./index.global.min.js",
39
+ "exports": {
40
+ "./package.json": "./package.json",
41
+ "./index.cjs": "./index.cjs",
42
+ "./index.js": "./index.js",
43
+ ".": {
44
+ "types": "./index.d.ts",
45
+ "require": "./index.cjs",
46
+ "import": "./index.js"
47
+ }
48
+ },
49
+ "sideEffects": false
50
+ }