From 3007009fab9a3257de14cb3de70f85c836be67ae Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 6 Apr 2019 10:22:03 +0200 Subject: upgrade cdav calendar to version 4 --- library/fullcalendar/packages/moment/main.js | 103 +++++++++++++++++++++++ library/fullcalendar/packages/moment/main.min.js | 6 ++ 2 files changed, 109 insertions(+) create mode 100644 library/fullcalendar/packages/moment/main.js create mode 100644 library/fullcalendar/packages/moment/main.min.js (limited to 'library/fullcalendar/packages/moment') diff --git a/library/fullcalendar/packages/moment/main.js b/library/fullcalendar/packages/moment/main.js new file mode 100644 index 000000000..ca94518a4 --- /dev/null +++ b/library/fullcalendar/packages/moment/main.js @@ -0,0 +1,103 @@ +/*! +FullCalendar Moment Plugin v4.0.2 +Docs & License: https://fullcalendar.io/ +(c) 2019 Adam Shaw +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('moment'), require('@fullcalendar/core')) : + typeof define === 'function' && define.amd ? define(['exports', 'moment', '@fullcalendar/core'], factory) : + (global = global || self, factory(global.FullCalendarMoment = {}, global.moment, global.FullCalendar)); +}(this, function (exports, moment, core) { 'use strict'; + + moment = moment && moment.hasOwnProperty('default') ? moment['default'] : moment; + + function toMoment(date, calendar) { + if (!(calendar instanceof core.Calendar)) { + throw new Error('must supply a Calendar instance'); + } + return convertToMoment(date, calendar.dateEnv.timeZone, null, calendar.dateEnv.locale.codes[0]); + } + function toDuration(fcDuration) { + return moment.duration(fcDuration); // momment accepts all the props that fc.Duration already has! + } + function formatWithCmdStr(cmdStr, arg) { + var cmd = parseCmdStr(cmdStr); + if (arg.end) { + var startMom = convertToMoment(arg.start.array, arg.timeZone, arg.start.timeZoneOffset, arg.localeCodes[0]); + var endMom = convertToMoment(arg.end.array, arg.timeZone, arg.end.timeZoneOffset, arg.localeCodes[0]); + return formatRange(cmd, createMomentFormatFunc(startMom), createMomentFormatFunc(endMom), arg.separator); + } + return convertToMoment(arg.date.array, arg.timeZone, arg.date.timeZoneOffset, arg.localeCodes[0]).format(cmd.whole); // TODO: test for this + } + var main = core.createPlugin({ + cmdFormatter: formatWithCmdStr + }); + function createMomentFormatFunc(mom) { + return function (cmdStr) { + return cmdStr ? mom.format(cmdStr) : ''; // because calling with blank string results in ISO8601 :( + }; + } + function convertToMoment(input, timeZone, timeZoneOffset, locale) { + var mom; + if (timeZone === 'local') { + mom = moment(input); + } + else if (timeZone === 'UTC') { + mom = moment.utc(input); + } + else if (moment.tz) { + mom = moment.tz(input, timeZone); + } + else { + mom = moment.utc(input); + if (timeZoneOffset != null) { + mom.utcOffset(timeZoneOffset); + } + } + mom.locale(locale); + return mom; + } + function parseCmdStr(cmdStr) { + var parts = cmdStr.match(/^(.*?)\{(.*)\}(.*)$/); // TODO: lookbehinds for escape characters + if (parts) { + var middle = parseCmdStr(parts[2]); + return { + head: parts[1], + middle: middle, + tail: parts[3], + whole: parts[1] + middle.whole + parts[3] + }; + } + else { + return { + head: null, + middle: null, + tail: null, + whole: cmdStr + }; + } + } + function formatRange(cmd, formatStart, formatEnd, separator) { + if (cmd.middle) { + var startHead = formatStart(cmd.head); + var startMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator); + var startTail = formatStart(cmd.tail); + var endHead = formatEnd(cmd.head); + var endMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator); + var endTail = formatEnd(cmd.tail); + if (startHead === endHead && startTail === endTail) { + return startHead + + (startMiddle === endMiddle ? startMiddle : startMiddle + separator + endMiddle) + + startTail; + } + } + return formatStart(cmd.whole) + separator + formatEnd(cmd.whole); + } + + exports.default = main; + exports.toDuration = toDuration; + exports.toMoment = toMoment; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/library/fullcalendar/packages/moment/main.min.js b/library/fullcalendar/packages/moment/main.min.js new file mode 100644 index 000000000..9b5b6d84e --- /dev/null +++ b/library/fullcalendar/packages/moment/main.min.js @@ -0,0 +1,6 @@ +/*! +FullCalendar Moment Plugin v4.0.2 +Docs & License: https://fullcalendar.io/ +(c) 2019 Adam Shaw +*/ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("moment"),require("@fullcalendar/core")):"function"==typeof define&&define.amd?define(["exports","moment","@fullcalendar/core"],t):(e=e||self,t(e.FullCalendarMoment={},e.moment,e.FullCalendar))}(this,function(e,t,n){"use strict";function r(e,t){if(!(t instanceof n.Calendar))throw new Error("must supply a Calendar instance");return u(e,t.dateEnv.timeZone,null,t.dateEnv.locale.codes[0])}function a(e){return t.duration(e)}function o(e,t){var n=i(e);if(t.end){var r=u(t.start.array,t.timeZone,t.start.timeZoneOffset,t.localeCodes[0]),a=u(t.end.array,t.timeZone,t.end.timeZoneOffset,t.localeCodes[0]);return d(n,l(r),l(a),t.separator)}return u(t.date.array,t.timeZone,t.date.timeZoneOffset,t.localeCodes[0]).format(n.whole)}function l(e){return function(t){return t?e.format(t):""}}function u(e,n,r,a){var o;return"local"===n?o=t(e):"UTC"===n?o=t.utc(e):t.tz?o=t.tz(e,n):(o=t.utc(e),null!=r&&o.utcOffset(r)),o.locale(a),o}function i(e){var t=e.match(/^(.*?)\{(.*)\}(.*)$/);if(t){var n=i(t[2]);return{head:t[1],middle:n,tail:t[3],whole:t[1]+n.whole+t[3]}}return{head:null,middle:null,tail:null,whole:e}}function d(e,t,n,r){if(e.middle){var a=t(e.head),o=d(e.middle,t,n,r),l=t(e.tail),u=n(e.head),i=d(e.middle,t,n,r),f=n(e.tail);if(a===u&&l===f)return a+(o===i?o:o+r+i)+l}return t(e.whole)+r+n(e.whole)}t=t&&t.hasOwnProperty("default")?t.default:t;var f=n.createPlugin({cmdFormatter:o});e.default=f,e.toDuration=a,e.toMoment=r,Object.defineProperty(e,"__esModule",{value:!0})}); \ No newline at end of file -- cgit v1.2.3