diff options
Diffstat (limited to 'public/js/fullcalendar/packages/moment/index.global.js')
-rw-r--r-- | public/js/fullcalendar/packages/moment/index.global.js | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/public/js/fullcalendar/packages/moment/index.global.js b/public/js/fullcalendar/packages/moment/index.global.js new file mode 100644 index 0000000..0133d4a --- /dev/null +++ b/public/js/fullcalendar/packages/moment/index.global.js | |||
@@ -0,0 +1,113 @@ | |||
1 | /*! | ||
2 | FullCalendar Moment Plugin v6.1.17 | ||
3 | Docs & License: https://fullcalendar.io/docs/moment-plugin | ||
4 | (c) 2024 Adam Shaw | ||
5 | */ | ||
6 | FullCalendar.Moment = (function (exports, core, moment, internal) { | ||
7 | 'use strict'; | ||
8 | |||
9 | function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; } | ||
10 | |||
11 | var moment__default = /*#__PURE__*/_interopDefault(moment); | ||
12 | |||
13 | function toMoment(date, calendar) { | ||
14 | if (!(calendar instanceof internal.CalendarImpl)) { | ||
15 | throw new Error('must supply a CalendarApi instance'); | ||
16 | } | ||
17 | let { dateEnv } = calendar.getCurrentData(); | ||
18 | return convertToMoment(date, dateEnv.timeZone, null, dateEnv.locale.codes[0]); | ||
19 | } | ||
20 | function toMomentDuration(fcDuration) { | ||
21 | return moment__default["default"].duration(fcDuration); // moment accepts all the props that fc.Duration already has! | ||
22 | } | ||
23 | // Internal Utils | ||
24 | function convertToMoment(input, timeZone, timeZoneOffset, locale) { | ||
25 | let mom; | ||
26 | if (timeZone === 'local') { | ||
27 | mom = moment__default["default"](input); | ||
28 | } | ||
29 | else if (timeZone === 'UTC') { | ||
30 | mom = moment__default["default"].utc(input); | ||
31 | } | ||
32 | else if (moment__default["default"].tz) { | ||
33 | mom = moment__default["default"].tz(input, timeZone); | ||
34 | } | ||
35 | else { | ||
36 | mom = moment__default["default"].utc(input); | ||
37 | if (timeZoneOffset != null) { | ||
38 | mom.utcOffset(timeZoneOffset); | ||
39 | } | ||
40 | } | ||
41 | mom.locale(locale); | ||
42 | return mom; | ||
43 | } | ||
44 | |||
45 | function formatWithCmdStr(cmdStr, arg) { | ||
46 | let cmd = parseCmdStr(cmdStr); | ||
47 | if (arg.end) { | ||
48 | let startMom = convertToMoment(arg.start.array, arg.timeZone, arg.start.timeZoneOffset, arg.localeCodes[0]); | ||
49 | let endMom = convertToMoment(arg.end.array, arg.timeZone, arg.end.timeZoneOffset, arg.localeCodes[0]); | ||
50 | return formatRange(cmd, createMomentFormatFunc(startMom), createMomentFormatFunc(endMom), arg.defaultSeparator); | ||
51 | } | ||
52 | return convertToMoment(arg.date.array, arg.timeZone, arg.date.timeZoneOffset, arg.localeCodes[0]).format(cmd.whole); // TODO: test for this | ||
53 | } | ||
54 | function createMomentFormatFunc(mom) { | ||
55 | return (cmdStr) => (cmdStr ? mom.format(cmdStr) : '' // because calling with blank string results in ISO8601 :( | ||
56 | ); | ||
57 | } | ||
58 | function parseCmdStr(cmdStr) { | ||
59 | let parts = cmdStr.match(/^(.*?)\{(.*)\}(.*)$/); // TODO: lookbehinds for escape characters | ||
60 | if (parts) { | ||
61 | let middle = parseCmdStr(parts[2]); | ||
62 | return { | ||
63 | head: parts[1], | ||
64 | middle, | ||
65 | tail: parts[3], | ||
66 | whole: parts[1] + middle.whole + parts[3], | ||
67 | }; | ||
68 | } | ||
69 | return { | ||
70 | head: null, | ||
71 | middle: null, | ||
72 | tail: null, | ||
73 | whole: cmdStr, | ||
74 | }; | ||
75 | } | ||
76 | function formatRange(cmd, formatStart, formatEnd, separator) { | ||
77 | if (cmd.middle) { | ||
78 | let startHead = formatStart(cmd.head); | ||
79 | let startMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator); | ||
80 | let startTail = formatStart(cmd.tail); | ||
81 | let endHead = formatEnd(cmd.head); | ||
82 | let endMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator); | ||
83 | let endTail = formatEnd(cmd.tail); | ||
84 | if (startHead === endHead && startTail === endTail) { | ||
85 | return startHead + | ||
86 | (startMiddle === endMiddle ? startMiddle : startMiddle + separator + endMiddle) + | ||
87 | startTail; | ||
88 | } | ||
89 | } | ||
90 | let startWhole = formatStart(cmd.whole); | ||
91 | let endWhole = formatEnd(cmd.whole); | ||
92 | if (startWhole === endWhole) { | ||
93 | return startWhole; | ||
94 | } | ||
95 | return startWhole + separator + endWhole; | ||
96 | } | ||
97 | |||
98 | var plugin = core.createPlugin({ | ||
99 | name: '@fullcalendar/moment', | ||
100 | cmdFormatter: formatWithCmdStr, | ||
101 | }); | ||
102 | |||
103 | core.globalPlugins.push(plugin); | ||
104 | |||
105 | exports["default"] = plugin; | ||
106 | exports.toMoment = toMoment; | ||
107 | exports.toMomentDuration = toMomentDuration; | ||
108 | |||
109 | Object.defineProperty(exports, '__esModule', { value: true }); | ||
110 | |||
111 | return exports; | ||
112 | |||
113 | })({}, FullCalendar, moment, FullCalendar.Internal); | ||