|
@@ -425,182 +425,7 @@ function Calendar_constructor(element, overrides) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- // Locale-data Internals
|
|
|
|
|
- // -----------------------------------------------------------------------------------
|
|
|
|
|
- // Apply overrides to the current locale's data
|
|
|
|
|
-
|
|
|
|
|
- var localeData;
|
|
|
|
|
-
|
|
|
|
|
- // Called immediately, and when any of the options change.
|
|
|
|
|
- // Happens before any internal objects rebuild or rerender, because this is very core.
|
|
|
|
|
- t.bindOptions([
|
|
|
|
|
- 'locale', 'monthNames', 'monthNamesShort', 'dayNames', 'dayNamesShort', 'firstDay', 'weekNumberCalculation'
|
|
|
|
|
- ], function(locale, monthNames, monthNamesShort, dayNames, dayNamesShort, firstDay, weekNumberCalculation) {
|
|
|
|
|
-
|
|
|
|
|
- // normalize
|
|
|
|
|
- if (weekNumberCalculation === 'iso') {
|
|
|
|
|
- weekNumberCalculation = 'ISO'; // normalize
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- localeData = createObject( // make a cheap copy
|
|
|
|
|
- getMomentLocaleData(locale) // will fall back to en
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- if (monthNames) {
|
|
|
|
|
- localeData._months = monthNames;
|
|
|
|
|
- }
|
|
|
|
|
- if (monthNamesShort) {
|
|
|
|
|
- localeData._monthsShort = monthNamesShort;
|
|
|
|
|
- }
|
|
|
|
|
- if (dayNames) {
|
|
|
|
|
- localeData._weekdays = dayNames;
|
|
|
|
|
- }
|
|
|
|
|
- if (dayNamesShort) {
|
|
|
|
|
- localeData._weekdaysShort = dayNamesShort;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (firstDay == null && weekNumberCalculation === 'ISO') {
|
|
|
|
|
- firstDay = 1;
|
|
|
|
|
- }
|
|
|
|
|
- if (firstDay != null) {
|
|
|
|
|
- var _week = createObject(localeData._week); // _week: { dow: # }
|
|
|
|
|
- _week.dow = firstDay;
|
|
|
|
|
- localeData._week = _week;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if ( // whitelist certain kinds of input
|
|
|
|
|
- weekNumberCalculation === 'ISO' ||
|
|
|
|
|
- weekNumberCalculation === 'local' ||
|
|
|
|
|
- typeof weekNumberCalculation === 'function'
|
|
|
|
|
- ) {
|
|
|
|
|
- localeData._fullCalendar_weekCalc = weekNumberCalculation; // moment-ext will know what to do with it
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // If the internal current date object already exists, move to new locale.
|
|
|
|
|
- // We do NOT need to do this technique for event dates, because this happens when converting to "segments".
|
|
|
|
|
- if (t.currentDate) {
|
|
|
|
|
- localizeMoment(t.currentDate); // sets to localeData
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // Calendar-specific Date Utilities
|
|
|
|
|
- // -----------------------------------------------------------------------------------
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- t.defaultAllDayEventDuration = moment.duration(t.options.defaultAllDayEventDuration);
|
|
|
|
|
- t.defaultTimedEventDuration = moment.duration(t.options.defaultTimedEventDuration);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // Builds a moment using the settings of the current calendar: timezone and locale.
|
|
|
|
|
- // Accepts anything the vanilla moment() constructor accepts.
|
|
|
|
|
- t.moment = function() {
|
|
|
|
|
- var mom;
|
|
|
|
|
-
|
|
|
|
|
- if (t.options.timezone === 'local') {
|
|
|
|
|
- mom = FC.moment.apply(null, arguments);
|
|
|
|
|
-
|
|
|
|
|
- // Force the moment to be local, because FC.moment doesn't guarantee it.
|
|
|
|
|
- if (mom.hasTime()) { // don't give ambiguously-timed moments a local zone
|
|
|
|
|
- mom.local();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else if (t.options.timezone === 'UTC') {
|
|
|
|
|
- mom = FC.moment.utc.apply(null, arguments); // process as UTC
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- mom = FC.moment.parseZone.apply(null, arguments); // let the input decide the zone
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- localizeMoment(mom);
|
|
|
|
|
-
|
|
|
|
|
- return mom;
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // Updates the given moment's locale settings to the current calendar locale settings.
|
|
|
|
|
- function localizeMoment(mom) {
|
|
|
|
|
- mom._locale = localeData;
|
|
|
|
|
- }
|
|
|
|
|
- t.localizeMoment = localizeMoment;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // Returns a boolean about whether or not the calendar knows how to calculate
|
|
|
|
|
- // the timezone offset of arbitrary dates in the current timezone.
|
|
|
|
|
- t.getIsAmbigTimezone = function() {
|
|
|
|
|
- return t.options.timezone !== 'local' && t.options.timezone !== 'UTC';
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // Returns a copy of the given date in the current timezone. Has no effect on dates without times.
|
|
|
|
|
- t.applyTimezone = function(date) {
|
|
|
|
|
- if (!date.hasTime()) {
|
|
|
|
|
- return date.clone();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- var zonedDate = t.moment(date.toArray());
|
|
|
|
|
- var timeAdjust = date.time() - zonedDate.time();
|
|
|
|
|
- var adjustedZonedDate;
|
|
|
|
|
-
|
|
|
|
|
- // Safari sometimes has problems with this coersion when near DST. Adjust if necessary. (bug #2396)
|
|
|
|
|
- if (timeAdjust) { // is the time result different than expected?
|
|
|
|
|
- adjustedZonedDate = zonedDate.clone().add(timeAdjust); // add milliseconds
|
|
|
|
|
- if (date.time() - adjustedZonedDate.time() === 0) { // does it match perfectly now?
|
|
|
|
|
- zonedDate = adjustedZonedDate;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return zonedDate;
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // Returns a moment for the current date, as defined by the client's computer or from the `now` option.
|
|
|
|
|
- // Will return an moment with an ambiguous timezone.
|
|
|
|
|
- t.getNow = function() {
|
|
|
|
|
- var now = t.options.now;
|
|
|
|
|
- if (typeof now === 'function') {
|
|
|
|
|
- now = now();
|
|
|
|
|
- }
|
|
|
|
|
- return t.moment(now).stripZone();
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // Get an event's normalized end date. If not present, calculate it from the defaults.
|
|
|
|
|
- t.getEventEnd = function(event) {
|
|
|
|
|
- if (event.end) {
|
|
|
|
|
- return event.end.clone();
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- return t.getDefaultEventEnd(event.allDay, event.start);
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // Given an event's allDay status and start date, return what its fallback end date should be.
|
|
|
|
|
- // TODO: rename to computeDefaultEventEnd
|
|
|
|
|
- t.getDefaultEventEnd = function(allDay, zonedStart) {
|
|
|
|
|
- var end = zonedStart.clone();
|
|
|
|
|
-
|
|
|
|
|
- if (allDay) {
|
|
|
|
|
- end.stripTime().add(t.defaultAllDayEventDuration);
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- end.add(t.defaultTimedEventDuration);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (t.getIsAmbigTimezone()) {
|
|
|
|
|
- end.stripZone(); // we don't know what the tzo should be
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return end;
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // Produces a human-readable string for the given duration.
|
|
|
|
|
- // Side-effect: changes the locale of the given duration.
|
|
|
|
|
- t.humanizeDuration = function(duration) {
|
|
|
|
|
- return duration.locale(t.options.locale).humanize();
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ t.initMomentInternals(); // needs to happen after options hash initialized
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|