Skip to content

Business intelligence made simple

Updated date range picker and moment, and added moment timezone

Andrew Kane5e385eb26b92
diff --git a/app/assets/javascripts/blazer/application.js b/app/assets/javascripts/blazer/application.js
index 4c16921d..e45f4442 100644
--- a/app/assets/javascripts/blazer/application.js
+++ b/app/assets/javascripts/blazer/application.js
@@ -6,6 +6,7 @@
//= require ./selectize
//= require ./highlight.pack
//= require ./moment
+//= require ./moment-timezone
//= require ./daterangepicker
//= require chartkick
//= require ./ace/ace
diff --git a/app/assets/javascripts/blazer/daterangepicker.js b/app/assets/javascripts/blazer/daterangepicker.js
index e4872ca1..b6401895 100644
--- a/app/assets/javascripts/blazer/daterangepicker.js
+++ b/app/assets/javascripts/blazer/daterangepicker.js
@@ -1,12 +1,36 @@
/**
-* @version: 1.3.7
+* @version: 1.3.19
* @author: Dan Grossman http://www.dangrossman.info/
-* @date: 2014-04-29
-* @copyright: Copyright (c) 2012-2014 Dan Grossman. All rights reserved.
-* @license: Licensed under Apache License v2.0. See http://www.apache.org/licenses/LICENSE-2.0
-* @website: http://www.improvely.com/
+* @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved.
+* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
+* @website: https://www.improvely.com/
*/
-!function ($, moment) {
+
+(function(root, factory) {
+
+ if (typeof define === 'function' && define.amd) {
+ define(['moment', 'jquery', 'exports'], function(momentjs, $, exports) {
+ root.daterangepicker = factory(root, exports, momentjs, $);
+ });
+
+ } else if (typeof exports !== 'undefined') {
+ var momentjs = require('moment');
+ var jQuery;
+ try {
+ jQuery = require('jquery');
+ } catch (err) {
+ jQuery = window.jQuery;
+ if (!jQuery) throw new Error('jQuery dependency not found');
+ }
+
+ factory(root, exports, momentjs, jQuery);
+
+ // Finally, as a browser global.
+ } else {
+ root.daterangepicker = factory(root, {}, root.moment, (root.jQuery || root.Zepto || root.ender || root.$));
+ }
+
+}(this, function(root, daterangepicker, moment, $) {
var DateRangePicker = function (element, options, cb) {
@@ -16,19 +40,22 @@
//element that triggered the date range picker
this.element = $(element);
+ //tracks visible state
+ this.isShowing = false;
+
//create the picker HTML object
var DRPTemplate = '<div class="daterangepicker dropdown-menu">' +
- '<div class="calendar left"></div>' +
- '<div class="calendar right"></div>' +
+ '<div class="calendar first left"></div>' +
+ '<div class="calendar second right"></div>' +
'<div class="ranges">' +
'<div class="range_inputs">' +
'<div class="daterangepicker_start_input">' +
'<label for="daterangepicker_start"></label>' +
- '<input class="input-mini" type="text" name="daterangepicker_start" value="" disabled="disabled" />' +
+ '<input class="input-mini" type="text" name="daterangepicker_start" value="" />' +
'</div>' +
'<div class="daterangepicker_end_input">' +
'<label for="daterangepicker_end"></label>' +
- '<input class="input-mini" type="text" name="daterangepicker_end" value="" disabled="disabled" />' +
+ '<input class="input-mini" type="text" name="daterangepicker_end" value="" />' +
'</div>' +
'<button class="applyBtn" disabled="disabled"></button>&nbsp;' +
'<button class="cancelBtn"></button>' +
@@ -65,16 +92,18 @@
.on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
.on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
.on('click.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
- .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.enterDate, this))
+ .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
.on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this))
.on('change.daterangepicker', 'select.yearselect', $.proxy(this.updateMonthYear, this))
.on('change.daterangepicker', 'select.monthselect', $.proxy(this.updateMonthYear, this))
- .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.ampmselect', $.proxy(this.updateTime, this));
+ .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.updateTime, this));
this.container.find('.ranges')
.on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
.on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
.on('click.daterangepicker', '.daterangepicker_start_input,.daterangepicker_end_input', $.proxy(this.showCalendars, this))
+ .on('change.daterangepicker', '.daterangepicker_start_input,.daterangepicker_end_input', $.proxy(this.inputsChanged, this))
+ .on('keydown.daterangepicker', '.daterangepicker_start_input,.daterangepicker_end_input', $.proxy(this.inputsKeydown, this))
.on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
.on('mouseenter.daterangepicker', 'li', $.proxy(this.enterRange, this))
.on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this));
@@ -99,6 +128,7 @@
this.startDate = moment().startOf('day');
this.endDate = moment().endOf('day');
+ this.timeZone = moment().utcOffset();
this.minDate = false;
this.maxDate = false;
this.dateLimit = false;
@@ -106,6 +136,7 @@
this.showDropdowns = false;
this.showWeekNumbers = false;
this.timePicker = false;
+ this.timePickerSeconds = false;
this.timePickerIncrement = 30;
this.timePicker12Hour = true;
this.singleDatePicker = false;
@@ -115,7 +146,7 @@
if (this.element.hasClass('pull-right'))
this.opens = 'left';
- this.buttonClasses = ['btn', 'btn-small'];
+ this.buttonClasses = ['btn', 'btn-small btn-sm'];
this.applyClass = 'btn-success';
this.cancelClass = 'btn-default';
@@ -129,9 +160,9 @@
toLabel: 'To',
weekLabel: 'W',
customRangeLabel: 'Custom Range',
- daysOfWeek: moment()._lang._weekdaysMin.slice(),
- monthNames: moment()._lang._monthsShort.slice(),
- firstDay: 0
+ daysOfWeek: moment.weekdaysMin(),
+ monthNames: moment.monthsShort(),
+ firstDay: moment.localeData()._week.dow
};
this.cb = function () { };
@@ -175,7 +206,6 @@
if (typeof options.dateLimit === 'object')
this.dateLimit = options.dateLimit;
- // update day names order to firstDay
if (typeof options.locale === 'object') {
if (typeof options.locale.daysOfWeek === 'object') {
@@ -189,12 +219,7 @@
}
if (typeof options.locale.firstDay === 'number') {
- this.locale.firstDay = options.locale.firstDay;
- var iterator = options.locale.firstDay;
- while (iterator > 0) {
- this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
- iterator--;
- }
+ this.locale.firstDay = options.locale.firstDay;
}
if (typeof options.locale.applyLabel === 'string') {
@@ -243,12 +268,19 @@
if (typeof options.singleDatePicker === 'boolean') {
this.singleDatePicker = options.singleDatePicker;
+ if (this.singleDatePicker) {
+ this.endDate = this.startDate.clone();
+ }
}
if (typeof options.timePicker === 'boolean') {
this.timePicker = options.timePicker;
}
+ if (typeof options.timePickerSeconds === 'boolean') {
+ this.timePickerSeconds = options.timePickerSeconds;
+ }
+
if (typeof options.timePickerIncrement === 'number') {
this.timePickerIncrement = options.timePickerIncrement;
}
@@ -257,18 +289,29 @@
this.timePicker12Hour = options.timePicker12Hour;
}
+ // update day names order to firstDay
+ if (this.locale.firstDay != 0) {
+ var iterator = this.locale.firstDay;
+ while (iterator > 0) {
+ this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
+ iterator--;
+ }
+ }
+
var start, end, range;
//if no start/end dates set, check if an input element contains initial values
if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
if ($(this.element).is('input[type=text]')) {
- var val = $(this.element).val();
- var split = val.split(this.separator);
+ var val = $(this.element).val(),
+ split = val.split(this.separator);
+
start = end = null;
+
if (split.length == 2) {
start = moment(split[0], this.format);
end = moment(split[1], this.format);
- } else if (this.singleDatePicker) {
+ } else if (this.singleDatePicker && val !== "") {
start = moment(val, this.format);
end = moment(val, this.format);
}
@@ -279,11 +322,27 @@
}
}
+ // bind the time zone used to build the calendar to either the timeZone passed in through the options or the zone of the startDate (which will be the local time zone by default)
+ if (typeof options.timeZone === 'string' || typeof options.timeZone === 'number') {
+ this.timeZone = options.timeZone;
+ this.startDate.utcOffset(this.timeZone);
+ this.endDate.utcOffset(this.timeZone);
+ } else {
+ this.timeZone = moment(this.startDate).utcOffset();
+ }
+
if (typeof options.ranges === 'object') {
for (range in options.ranges) {
- start = moment(options.ranges[range][0]);
- end = moment(options.ranges[range][1]);
+ if (typeof options.ranges[range][0] === 'string')
+ start = moment(options.ranges[range][0], this.format);
+ else
+ start = moment(options.ranges[range][0]);
+
+ if (typeof options.ranges[range][1] === 'string')
+ end = moment(options.ranges[range][1], this.format);
+ else
+ end = moment(options.ranges[range][1]);
// If we have a min/max date set, bound this range
// to it, but only if it would otherwise fall
@@ -325,12 +384,18 @@
if (this.singleDatePicker) {
this.opens = 'right';
+ this.container.addClass('single');
this.container.find('.calendar.right').show();
this.container.find('.calendar.left').hide();
- this.container.find('.ranges').hide();
+ if (!this.timePicker) {
+ this.container.find('.ranges').hide();
+ } else {
+ this.container.find('.ranges .daterangepicker_start_input, .ranges .daterangepicker_end_input').hide();
+ }
if (!this.container.find('.calendar.right').hasClass('single'))
this.container.find('.calendar.right').addClass('single');
} else {
+ this.container.removeClass('single');
this.container.find('.calendar.right').removeClass('single');
this.container.find('.ranges').show();
}
@@ -340,21 +405,32 @@
this.oldChosenLabel = this.chosenLabel;
this.leftCalendar = {
- month: moment([this.startDate.year(), this.startDate.month(), 1, this.startDate.hour(), this.startDate.minute()]),
+ month: moment([this.startDate.year(), this.startDate.month(), 1, this.startDate.hour(), this.startDate.minute(), this.startDate.second()]),
calendar: []
};
this.rightCalendar = {
- month: moment([this.endDate.year(), this.endDate.month(), 1, this.endDate.hour(), this.endDate.minute()]),
+ month: moment([this.endDate.year(), this.endDate.month(), 1, this.endDate.hour(), this.endDate.minute(), this.endDate.second()]),
calendar: []
};
- if (this.opens == 'right') {
+ if (this.opens == 'right' || this.opens == 'center') {
//swap calendar positions
- var left = this.container.find('.calendar.left');
- var right = this.container.find('.calendar.right');
- left.removeClass('left').addClass('right');
- right.removeClass('right').addClass('left');
+ var first = this.container.find('.calendar.first');
+ var second = this.container.find('.calendar.second');
+
+ if (second.hasClass('single')) {
+ second.removeClass('single');
+ first.addClass('single');
+ }
+
+ first.removeClass('left').addClass('right');
+ second.removeClass('right').addClass('left');
+
+ if (this.singleDatePicker) {
+ first.show();
+ second.hide();
+ }
}
if (typeof options.ranges === 'undefined' && !this.singleDatePicker) {
@@ -370,7 +446,7 @@
setStartDate: function(startDate) {
if (typeof startDate === 'string')
- this.startDate = moment(startDate, this.format);
+ this.startDate = moment(startDate, this.format).utcOffset(this.timeZone);
if (typeof startDate === 'object')
this.startDate = moment(startDate);
@@ -382,11 +458,12 @@
this.updateView();
this.updateCalendars();
+ this.updateInputText();
},
setEndDate: function(endDate) {
if (typeof endDate === 'string')
- this.endDate = moment(endDate, this.format);
+ this.endDate = moment(endDate, this.format).utcOffset(this.timeZone);
if (typeof endDate === 'object')
this.endDate = moment(endDate);
@@ -398,11 +475,12 @@
this.updateView();
this.updateCalendars();
+ this.updateInputText();
},
updateView: function () {
- this.leftCalendar.month.month(this.startDate.month()).year(this.startDate.year());
- this.rightCalendar.month.month(this.endDate.month()).year(this.endDate.year());
+ this.leftCalendar.month.month(this.startDate.month()).year(this.startDate.year()).hour(this.startDate.hour()).minute(this.startDate.minute());
+ this.rightCalendar.month.month(this.endDate.month()).year(this.endDate.year()).hour(this.endDate.hour()).minute(this.endDate.minute());
this.updateFormInputs();
},
@@ -426,12 +504,12 @@
end = null;
if(dateString.length === 2) {
- start = moment(dateString[0], this.format);
- end = moment(dateString[1], this.format);
+ start = moment(dateString[0], this.format).utcOffset(this.timeZone);
+ end = moment(dateString[1], this.format).utcOffset(this.timeZone);
}
if (this.singleDatePicker || start === null || end === null) {
- start = moment(this.element.val(), this.format);
+ start = moment(this.element.val(), this.format).utcOffset(this.timeZone);
end = start;
}
@@ -456,17 +534,19 @@
move: function () {
var parentOffset = { top: 0, left: 0 };
+ var parentRightEdge = $(window).width();
if (!this.parentEl.is('body')) {
parentOffset = {
top: this.parentEl.offset().top - this.parentEl.scrollTop(),
left: this.parentEl.offset().left - this.parentEl.scrollLeft()
};
+ parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left;
}
if (this.opens == 'left') {
this.container.css({
top: this.element.offset().top + this.element.outerHeight() - parentOffset.top,
- right: $(window).width() - this.element.offset().left - this.element.outerWidth() - parentOffset.left,
+ right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
left: 'auto'
});
if (this.container.offset().left < 0) {
@@ -475,6 +555,19 @@
left: 9
});
}
+ } else if (this.opens == 'center') {
+ this.container.css({
+ top: this.element.offset().top + this.element.outerHeight() - parentOffset.top,
+ left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
+ - this.container.outerWidth() / 2,
+ right: 'auto'
+ });
+ if (this.container.offset().left < 0) {
+ this.container.css({
+ right: 'auto',
+ left: 9
+ });
+ }
} else {
this.container.css({
top: this.element.offset().top + this.element.outerHeight() - parentOffset.top,
@@ -499,6 +592,8 @@
},
show: function (e) {
+ if (this.isShowing) return;
+
this.element.addClass('active');
this.container.show();
this.move();
@@ -508,11 +603,14 @@
// Bind global datepicker mousedown for hiding and
$(document)
.on('mousedown.daterangepicker', this._outsideClickProxy)
+ // also support mobile devices
+ .on('touchend.daterangepicker', this._outsideClickProxy)
// also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
.on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
// and also close when focus changes to outside the picker (eg. tabbing between controls)
.on('focusin.daterangepicker', this._outsideClickProxy);
+ this.isShowing = true;
this.element.trigger('show.daterangepicker', this);
},
@@ -521,6 +619,8 @@
// if the page is clicked anywhere except within the daterangerpicker/button
// itself then call this.hide()
if (
+ // ie modal dialog fix
+ e.type == "focusin" ||
target.closest(this.element).length ||
target.closest(this.container).length ||
target.closest('.calendar-date').length
@@ -529,10 +629,10 @@
},
hide: function (e) {
+ if (!this.isShowing) return;
+
$(document)
- .off('mousedown.daterangepicker', this._outsideClickProxy)
- .off('click.daterangepicker', this._outsideClickProxy)
- .off('focusin.daterangepicker', this._outsideClickProxy);
+ .off('.daterangepicker');
this.element.removeClass('active');
this.container.hide();
@@ -543,6 +643,7 @@
this.oldStartDate = this.startDate.clone();
this.oldEndDate = this.endDate.clone();
+ this.isShowing = false;
this.element.trigger('hide.daterangepicker', this);
},
@@ -561,17 +662,45 @@
showCalendars: function() {
this.container.addClass('show-calendar');
this.move();
+ this.element.trigger('showCalendar.daterangepicker', this);
},
hideCalendars: function() {
this.container.removeClass('show-calendar');
+ this.element.trigger('hideCalendar.daterangepicker', this);
+ },
+
+ // when a date is typed into the start to end date textboxes
+ inputsChanged: function (e) {
+ var el = $(e.target);
+ var date = moment(el.val(), this.format);
+ if (!date.isValid()) return;
+
+ var startDate, endDate;
+ if (el.attr('name') === 'daterangepicker_start') {
+ startDate = (false !== this.minDate && date.isBefore(this.minDate)) ? this.minDate : date;
+ endDate = this.endDate;
+ } else {
+ startDate = this.startDate;
+ endDate = (false !== this.maxDate && date.isAfter(this.maxDate)) ? this.maxDate : date;
+ }
+ this.setCustomDates(startDate, endDate);
+ },
+
+ inputsKeydown: function(e) {
+ if (e.keyCode === 13) {
+ this.inputsChanged(e);
+ this.notify();
+ }
},
updateInputText: function() {
if (this.element.is('input') && !this.singleDatePicker) {
this.element.val(this.startDate.format(this.format) + this.separator + this.endDate.format(this.format));
+ this.element.trigger('change');
} else if (this.element.is('input')) {
- this.element.val(this.startDate.format(this.format));
+ this.element.val(this.endDate.format(this.format));
+ this.element.trigger('change');
}
},
@@ -606,9 +735,9 @@
clickPrev: function (e) {
var cal = $(e.target).parents('.calendar');
if (cal.hasClass('left')) {
- this.leftCalendar.month.subtract('month', 1);
+ this.leftCalendar.month.subtract(1, 'month');
} else {
- this.rightCalendar.month.subtract('month', 1);
+ this.rightCalendar.month.subtract(1, 'month');
}
this.updateCalendars();
},
@@ -616,15 +745,14 @@
clickNext: function (e) {
var cal = $(e.target).parents('.calendar');
if (cal.hasClass('left')) {
- this.leftCalendar.month.add('month', 1);
+ this.leftCalendar.month.add(1, 'month');
} else {
- this.rightCalendar.month.add('month', 1);
+ this.rightCalendar.month.add(1, 'month');
}
this.updateCalendars();
},
- enterDate: function (e) {
-
+ hoverDate: function (e) {
var title = $(e.target).attr('data-title');
var row = title.substr(1, 1);
var col = title.substr(3, 1);
@@ -635,7 +763,22 @@
} else {
this.container.find('input[name=daterangepicker_end]').val(this.rightCalendar.calendar[row][col].format(this.format));
}
+ },
+
+ setCustomDates: function(startDate, endDate) {
+ this.chosenLabel = this.locale.customRangeLabel;
+ if (startDate.isAfter(endDate)) {
+ var difference = this.endDate.diff(this.startDate);
+ endDate = moment(startDate).add(difference, 'ms');
+ if (this.maxDate && endDate.isAfter(this.maxDate)) {
+ endDate = this.maxDate;
+ }
+ }
+ this.startDate = startDate;
+ this.endDate = endDate;
+ this.updateView();
+ this.updateCalendars();
},
clickDate: function (e) {
@@ -673,27 +816,14 @@
cal.find('td').removeClass('active');
- if (startDate.isSame(endDate) || startDate.isBefore(endDate)) {
- $(e.target).addClass('active');
- this.startDate = startDate;
- this.endDate = endDate;
- this.chosenLabel = this.locale.customRangeLabel;
- } else if (startDate.isAfter(endDate)) {
- $(e.target).addClass('active');
- var difference = this.endDate.diff(this.startDate);
- this.startDate = startDate;
- this.endDate = moment(startDate).add('ms', difference);
- this.chosenLabel = this.locale.customRangeLabel;
- }
+ $(e.target).addClass('active');
- this.leftCalendar.month.month(this.startDate.month()).year(this.startDate.year());
- this.rightCalendar.month.month(this.endDate.month()).year(this.endDate.year());
- this.updateCalendars();
+ this.setCustomDates(startDate, endDate);
if (!this.timePicker)
endDate.endOf('day');
- if (this.singleDatePicker)
+ if (this.singleDatePicker && !this.timePicker)
this.clickApply();
},
@@ -722,6 +852,28 @@
var month = parseInt(cal.find('.monthselect').val(), 10);
var year = cal.find('.yearselect').val();
+ if (!isLeft && !this.singleDatePicker) {
+ if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) {
+ month = this.startDate.month();
+ year = this.startDate.year();
+ }
+ }
+
+ if (this.minDate) {
+ if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) {
+ month = this.minDate.month();
+ year = this.minDate.year();
+ }
+ }
+
+ if (this.maxDate) {
+ if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) {
+ month = this.maxDate.month();
+ year = this.maxDate.year();
+ }
+ }
+
+
this[leftOrRight+'Calendar'].month.month(month).year(year);
this.updateCalendars();
},
@@ -733,6 +885,11 @@
var hour = parseInt(cal.find('.hourselect').val(), 10);
var minute = parseInt(cal.find('.minuteselect').val(), 10);
+ var second = 0;
+
+ if (this.timePickerSeconds) {
+ second = parseInt(cal.find('.secondselect').val(), 10);
+ }
if (this.timePicker12Hour) {
var ampm = cal.find('.ampmselect').val();
@@ -746,24 +903,31 @@
var start = this.startDate.clone();
start.hour(hour);
start.minute(minute);
+ start.second(second);
this.startDate = start;
- this.leftCalendar.month.hour(hour).minute(minute);
+ this.leftCalendar.month.hour(hour).minute(minute).second(second);
+ if (this.singleDatePicker)
+ this.endDate = start.clone();
} else {
var end = this.endDate.clone();
end.hour(hour);
end.minute(minute);
+ end.second(second);
this.endDate = end;
- this.rightCalendar.month.hour(hour).minute(minute);
+ if (this.singleDatePicker)
+ this.startDate = end.clone();
+ this.rightCalendar.month.hour(hour).minute(minute).second(second);
}
+ this.updateView();
this.updateCalendars();
},
updateCalendars: function () {
- this.leftCalendar.calendar = this.buildCalendar(this.leftCalendar.month.month(), this.leftCalendar.month.year(), this.leftCalendar.month.hour(), this.leftCalendar.month.minute(), 'left');
- this.rightCalendar.calendar = this.buildCalendar(this.rightCalendar.month.month(), this.rightCalendar.month.year(), this.rightCalendar.month.hour(), this.rightCalendar.month.minute(), 'right');
- this.container.find('.calendar.left').empty().html(this.renderCalendar(this.leftCalendar.calendar, this.startDate, this.minDate, this.maxDate));
- this.container.find('.calendar.right').empty().html(this.renderCalendar(this.rightCalendar.calendar, this.endDate, this.startDate, this.maxDate));
+ this.leftCalendar.calendar = this.buildCalendar(this.leftCalendar.month.month(), this.leftCalendar.month.year(), this.leftCalendar.month.hour(), this.leftCalendar.month.minute(), this.leftCalendar.month.second(), 'left');
+ this.rightCalendar.calendar = this.buildCalendar(this.rightCalendar.month.month(), this.rightCalendar.month.year(), this.rightCalendar.month.hour(), this.rightCalendar.month.minute(), this.rightCalendar.month.second(), 'right');
+ this.container.find('.calendar.left').empty().html(this.renderCalendar(this.leftCalendar.calendar, this.startDate, this.minDate, this.maxDate, 'left'));
+ this.container.find('.calendar.right').empty().html(this.renderCalendar(this.rightCalendar.calendar, this.endDate, this.singleDatePicker ? this.minDate : this.startDate, this.maxDate, 'right'));
this.container.find('.ranges li').removeClass('active');
var customRange = true;
@@ -786,15 +950,17 @@
i++;
}
if (customRange) {
- this.chosenLabel = this.container.find('.ranges li:last')
- .addClass('active').html();
+ this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html();
+ this.showCalendars();
}
},
- buildCalendar: function (month, year, hour, minute, side) {
+ buildCalendar: function (month, year, hour, minute, second, side) {
+ var daysInMonth = moment([year, month]).daysInMonth();
var firstDay = moment([year, month, 1]);
- var lastMonth = moment(firstDay).subtract('month', 1).month();
- var lastYear = moment(firstDay).subtract('month', 1).year();
+ var lastDay = moment([year, month, daysInMonth]);
+ var lastMonth = moment(firstDay).subtract(1, 'month').month();
+ var lastYear = moment(firstDay).subtract(1, 'month').year();
var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth();
@@ -804,6 +970,9 @@
//initialize a 6 rows x 7 columns array for the calendar
var calendar = [];
+ calendar.firstDay = firstDay;
+ calendar.lastDay = lastDay;
+
for (i = 0; i < 6; i++) {
calendar[i] = [];
}
@@ -816,15 +985,25 @@
if (dayOfWeek == this.locale.firstDay)
startDay = daysInLastMonth - 6;
- var curDate = moment([lastYear, lastMonth, startDay, 12, minute]);
+ var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]).utcOffset(this.timeZone);
+
var col, row;
- for (i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add('hour', 24)) {
+ for (i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) {
if (i > 0 && col % 7 === 0) {
col = 0;
row++;
}
calendar[row][col] = curDate.clone().hour(hour);
curDate.hour(12);
+
+ if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
+ calendar[row][col] = this.minDate.clone();
+ }
+
+ if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
+ calendar[row][col] = this.maxDate.clone();
+ }
+
}
return calendar;
@@ -832,9 +1011,13 @@
renderDropdowns: function (selected, minDate, maxDate) {
var currentMonth = selected.month();
+ var currentYear = selected.year();
+ var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
+ var minYear = (minDate && minDate.year()) || (currentYear - 50);
+
var monthHtml = '<select class="monthselect">';
- var inMinYear = false;
- var inMaxYear = false;
+ var inMinYear = currentYear == minYear;
+ var inMaxYear = currentYear == maxYear;
for (var m = 0; m < 12; m++) {
if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
@@ -845,9 +1028,6 @@
}
monthHtml += "</select>";
- var currentYear = selected.year();
- var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
- var minYear = (minDate && minDate.year()) || (currentYear - 50);
var yearHtml = '<select class="yearselect">';
for (var y = minYear; y <= maxYear; y++) {
@@ -861,7 +1041,7 @@
return monthHtml + yearHtml;
},
- renderCalendar: function (calendar, selected, minDate, maxDate) {
+ renderCalendar: function (calendar, selected, minDate, maxDate, side) {
var html = '<div class="calendar-date">';
html += '<table class="table-condensed">';
@@ -872,8 +1052,8 @@
if (this.showWeekNumbers)
html += '<th></th>';
- if (!minDate || minDate.isBefore(calendar[1][1])) {
- html += '<th class="prev available"><i class="fa fa-arrow-left icon-arrow-left glyphicon glyphicon-arrow-left"></i></th>';
+ if (!minDate || minDate.isBefore(calendar.firstDay)) {
+ html += '<th class="prev available"><i class="fa fa-arrow-left icon icon-arrow-left glyphicon glyphicon-arrow-left"></i></th>';
} else {
html += '<th></th>';
}
@@ -885,8 +1065,8 @@
}
html += '<th colspan="5" class="month">' + dateHtml + '</th>';
- if (!maxDate || maxDate.isAfter(calendar[1][1])) {
- html += '<th class="next available"><i class="fa fa-arrow-right icon-arrow-right glyphicon glyphicon-arrow-right"></i></th>';
+ if (!maxDate || maxDate.isAfter(calendar.lastDay)) {
+ html += '<th class="next available"><i class="fa fa-arrow-right icon icon-arrow-right glyphicon glyphicon-arrow-right"></i></th>';
} else {
html += '<th></th>';
}
@@ -948,6 +1128,29 @@
html += '<div class="calendar-time">';
html += '<select class="hourselect">';
+
+ // Disallow selections before the minDate or after the maxDate
+ var min_hour = 0;
+ var max_hour = 23;
+
+ if (minDate && (side == 'left' || this.singleDatePicker) && selected.format('YYYY-MM-DD') == minDate.format('YYYY-MM-DD')) {
+ min_hour = minDate.hour();
+ if (selected.hour() < min_hour)
+ selected.hour(min_hour);
+ if (this.timePicker12Hour && min_hour >= 12 && selected.hour() >= 12)
+ min_hour -= 12;
+ if (this.timePicker12Hour && min_hour == 12)
+ min_hour = 1;
+ }
+
+ if (maxDate && (side == 'right' || this.singleDatePicker) && selected.format('YYYY-MM-DD') == maxDate.format('YYYY-MM-DD')) {
+ max_hour = maxDate.hour();
+ if (selected.hour() > max_hour)
+ selected.hour(max_hour);
+ if (this.timePicker12Hour && max_hour >= 12 && selected.hour() >= 12)
+ max_hour -= 12;
+ }
+
var start = 0;
var end = 23;
var selected_hour = selected.hour();
@@ -961,8 +1164,11 @@
}
for (i = start; i <= end; i++) {
+
if (i == selected_hour) {
html += '<option value="' + i + '" selected="selected">' + i + '</option>';
+ } else if (i < min_hour || i > max_hour) {
+ html += '<option value="' + i + '" disabled="disabled" class="disabled">' + i + '</option>';
} else {
html += '<option value="' + i + '">' + i + '</option>';
}
@@ -972,12 +1178,30 @@
html += '<select class="minuteselect">';
+ // Disallow selections before the minDate or after the maxDate
+ var min_minute = 0;
+ var max_minute = 59;
+
+ if (minDate && (side == 'left' || this.singleDatePicker) && selected.format('YYYY-MM-DD h A') == minDate.format('YYYY-MM-DD h A')) {
+ min_minute = minDate.minute();
+ if (selected.minute() < min_minute)
+ selected.minute(min_minute);
+ }
+
+ if (maxDate && (side == 'right' || this.singleDatePicker) && selected.format('YYYY-MM-DD h A') == maxDate.format('YYYY-MM-DD h A')) {
+ max_minute = maxDate.minute();
+ if (selected.minute() > max_minute)
+ selected.minute(max_minute);
+ }
+
for (i = 0; i < 60; i += this.timePickerIncrement) {
var num = i;
if (num < 10)
num = '0' + num;
if (i == selected.minute()) {
html += '<option value="' + i + '" selected="selected">' + num + '</option>';
+ } else if (i < min_minute || i > max_minute) {
+ html += '<option value="' + i + '" disabled="disabled" class="disabled">' + num + '</option>';
} else {
html += '<option value="' + i + '">' + num + '</option>';
}
@@ -985,12 +1209,42 @@
html += '</select> ';
+ if (this.timePickerSeconds) {
+ html += ': <select class="secondselect">';
+
+ for (i = 0; i < 60; i += this.timePickerIncrement) {
+ var num = i;
+ if (num < 10)
+ num = '0' + num;
+ if (i == selected.second()) {
+ html += '<option value="' + i + '" selected="selected">' + num + '</option>';
+ } else {
+ html += '<option value="' + i + '">' + num + '</option>';
+ }
+ }
+
+ html += '</select>';
+ }
+
if (this.timePicker12Hour) {
html += '<select class="ampmselect">';
+
+ // Disallow selection before the minDate or after the maxDate
+ var am_html = '';
+ var pm_html = '';
+
+ if (minDate && (side == 'left' || this.singleDatePicker) && selected.format('YYYY-MM-DD') == minDate.format('YYYY-MM-DD') && minDate.hour() >= 12) {
+ am_html = ' disabled="disabled" class="disabled"';
+ }
+
+ if (maxDate && (side == 'right' || this.singleDatePicker) && selected.format('YYYY-MM-DD') == maxDate.format('YYYY-MM-DD') && maxDate.hour() < 12) {
+ pm_html = ' disabled="disabled" class="disabled"';
+ }
+
if (selected.hour() >= 12) {
- html += '<option value="AM">AM</option><option value="PM" selected="selected">PM</option>';
+ html += '<option value="AM"' + am_html + '>AM</option><option value="PM" selected="selected"' + pm_html + '>PM</option>';
} else {
- html += '<option value="AM" selected="selected">AM</option><option value="PM">PM</option>';
+ html += '<option value="AM" selected="selected"' + am_html + '>AM</option><option value="PM"' + pm_html + '>PM</option>';
}
html += '</select>';
}
@@ -1023,4 +1277,4 @@
return this;
};
-}(window.jQuery, window.moment);
+}));
diff --git a/app/assets/javascripts/blazer/moment-timezone.js b/app/assets/javascripts/blazer/moment-timezone.js
new file mode 100644
index 00000000..2dba4c7d
--- /dev/null
+++ b/app/assets/javascripts/blazer/moment-timezone.js
@@ -0,0 +1,1007 @@
+//! moment-timezone.js
+//! version : 0.3.0
+//! author : Tim Wood
+//! license : MIT
+//! github.com/moment/moment-timezone
+
+(function (root, factory) {
+ "use strict";
+
+ /*global define*/
+ if (typeof define === 'function' && define.amd) {
+ define(['moment'], factory); // AMD
+ } else if (typeof exports === 'object') {
+ module.exports = factory(require('moment')); // Node
+ } else {
+ factory(root.moment); // Browser
+ }
+}(this, function (moment) {
+ "use strict";
+
+ // Do not load moment-timezone a second time.
+ if (moment.tz !== undefined) { return moment; }
+
+ var VERSION = "0.3.0",
+ zones = {},
+ links = {},
+
+ momentVersion = moment.version.split('.'),
+ major = +momentVersion[0],
+ minor = +momentVersion[1];
+
+ // Moment.js version check
+ if (major < 2 || (major === 2 && minor < 6)) {
+ logError('Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js ' + moment.version + '. See momentjs.com');
+ }
+
+ /************************************
+ Unpacking
+ ************************************/
+
+ function charCodeToInt(charCode) {
+ if (charCode > 96) {
+ return charCode - 87;
+ } else if (charCode > 64) {
+ return charCode - 29;
+ }
+ return charCode - 48;
+ }
+
+ function unpackBase60(string) {
+ var i = 0,
+ parts = string.split('.'),
+ whole = parts[0],
+ fractional = parts[1] || '',
+ multiplier = 1,
+ num,
+ out = 0,
+ sign = 1;
+
+ // handle negative numbers
+ if (string.charCodeAt(0) === 45) {
+ i = 1;
+ sign = -1;
+ }
+
+ // handle digits before the decimal
+ for (i; i < whole.length; i++) {
+ num = charCodeToInt(whole.charCodeAt(i));
+ out = 60 * out + num;
+ }
+
+ // handle digits after the decimal
+ for (i = 0; i < fractional.length; i++) {
+ multiplier = multiplier / 60;
+ num = charCodeToInt(fractional.charCodeAt(i));
+ out += num * multiplier;
+ }
+
+ return out * sign;
+ }
+
+ function arrayToInt (array) {
+ for (var i = 0; i < array.length; i++) {
+ array[i] = unpackBase60(array[i]);
+ }
+ }
+
+ function intToUntil (array, length) {
+ for (var i = 0; i < length; i++) {
+ array[i] = Math.round((array[i - 1] || 0) + (array[i] * 60000)); // minutes to milliseconds
+ }
+
+ array[length - 1] = Infinity;
+ }
+
+ function mapIndices (source, indices) {
+ var out = [], i;
+
+ for (i = 0; i < indices.length; i++) {
+ out[i] = source[indices[i]];
+ }
+
+ return out;
+ }
+
+ function unpack (string) {
+ var data = string.split('|'),
+ offsets = data[2].split(' '),
+ indices = data[3].split(''),
+ untils = data[4].split(' ');
+
+ arrayToInt(offsets);
+ arrayToInt(indices);
+ arrayToInt(untils);
+
+ intToUntil(untils, indices.length);
+
+ return {
+ name : data[0],
+ abbrs : mapIndices(data[1].split(' '), indices),
+ offsets : mapIndices(offsets, indices),
+ untils : untils
+ };
+ }
+
+ /************************************
+ Zone object
+ ************************************/
+
+ function Zone (packedString) {
+ if (packedString) {
+ this._set(unpack(packedString));
+ }
+ }
+
+ Zone.prototype = {
+ _set : function (unpacked) {
+ this.name = unpacked.name;
+ this.abbrs = unpacked.abbrs;
+ this.untils = unpacked.untils;
+ this.offsets = unpacked.offsets;
+ },
+
+ _index : function (timestamp) {
+ var target = +timestamp,
+ untils = this.untils,
+ i;
+
+ for (i = 0; i < untils.length; i++) {
+ if (target < untils[i]) {
+ return i;
+ }
+ }
+ },
+
+ parse : function (timestamp) {
+ var target = +timestamp,
+ offsets = this.offsets,
+ untils = this.untils,
+ max = untils.length - 1,
+ offset, offsetNext, offsetPrev, i;
+
+ for (i = 0; i < max; i++) {
+ offset = offsets[i];
+ offsetNext = offsets[i + 1];
+ offsetPrev = offsets[i ? i - 1 : i];
+
+ if (offset < offsetNext && tz.moveAmbiguousForward) {
+ offset = offsetNext;
+ } else if (offset > offsetPrev && tz.moveInvalidForward) {
+ offset = offsetPrev;
+ }
+
+ if (target < untils[i] - (offset * 60000)) {
+ return offsets[i];
+ }
+ }
+
+ return offsets[max];
+ },
+
+ abbr : function (mom) {
+ return this.abbrs[this._index(mom)];
+ },
+
+ offset : function (mom) {
+ return this.offsets[this._index(mom)];
+ }
+ };
+
+ /************************************
+ Global Methods
+ ************************************/
+
+ function normalizeName (name) {
+ return (name || '').toLowerCase().replace(/\//g, '_');
+ }
+
+ function addZone (packed) {
+ var i, zone, zoneName;
+
+ if (typeof packed === "string") {
+ packed = [packed];
+ }
+
+ for (i = 0; i < packed.length; i++) {
+ zone = new Zone(packed[i]);
+ zoneName = normalizeName(zone.name);
+ zones[zoneName] = zone;
+ upgradeLinksToZones(zoneName);
+ }
+ }
+
+ function getZone (name) {
+ return zones[normalizeName(name)] || null;
+ }
+
+ function getNames () {
+ var i, out = [];
+
+ for (i in zones) {
+ if (zones.hasOwnProperty(i) && zones[i]) {
+ out.push(zones[i].name);
+ }
+ }
+
+ return out.sort();
+ }
+
+ function addLink (aliases) {
+ var i, alias;
+
+ if (typeof aliases === "string") {
+ aliases = [aliases];
+ }
+
+ for (i = 0; i < aliases.length; i++) {
+ alias = aliases[i].split('|');
+ pushLink(alias[0], alias[1]);
+ pushLink(alias[1], alias[0]);
+ }
+ }
+
+ function upgradeLinksToZones (zoneName) {
+ if (!links[zoneName]) {
+ return;
+ }
+
+ var i,
+ zone = zones[zoneName],
+ linkNames = links[zoneName];
+
+ for (i = 0; i < linkNames.length; i++) {
+ copyZoneWithName(zone, linkNames[i]);
+ }
+
+ links[zoneName] = null;
+ }
+
+ function copyZoneWithName (zone, name) {
+ var linkZone = zones[normalizeName(name)] = new Zone();
+ linkZone._set(zone);
+ linkZone.name = name;
+ }
+
+ function pushLink (zoneName, linkName) {
+ zoneName = normalizeName(zoneName);
+
+ if (zones[zoneName]) {
+ copyZoneWithName(zones[zoneName], linkName);
+ } else {
+ links[zoneName] = links[zoneName] || [];
+ links[zoneName].push(linkName);
+ }
+ }
+
+ function loadData (data) {
+ addZone(data.zones);
+ addLink(data.links);
+ tz.dataVersion = data.version;
+ }
+
+ function zoneExists (name) {
+ if (!zoneExists.didShowError) {
+ zoneExists.didShowError = true;
+ logError("moment.tz.zoneExists('" + name + "') has been deprecated in favor of !moment.tz.zone('" + name + "')");
+ }
+ return !!getZone(name);
+ }
+
+ function needsOffset (m) {
+ return !!(m._a && (m._tzm === undefined));
+ }
+
+ function logError (message) {
+ if (typeof console !== 'undefined' && typeof console.error === 'function') {
+ console.error(message);
+ }
+ }
+
+ /************************************
+ moment.tz namespace
+ ************************************/
+
+ function tz (input) {
+ var args = Array.prototype.slice.call(arguments, 0, -1),
+ name = arguments[arguments.length - 1],
+ zone = getZone(name),
+ out = moment.utc.apply(null, args);
+
+ if (zone && !moment.isMoment(input) && needsOffset(out)) {
+ out.add(zone.parse(out), 'minutes');
+ }
+
+ out.tz(name);
+
+ return out;
+ }
+
+ tz.version = VERSION;
+ tz.dataVersion = '';
+ tz._zones = zones;
+ tz._links = links;
+ tz.add = addZone;
+ tz.link = addLink;
+ tz.load = loadData;
+ tz.zone = getZone;
+ tz.zoneExists = zoneExists; // deprecated in 0.1.0
+ tz.names = getNames;
+ tz.Zone = Zone;
+ tz.unpack = unpack;
+ tz.unpackBase60 = unpackBase60;
+ tz.needsOffset = needsOffset;
+ tz.moveInvalidForward = true;
+ tz.moveAmbiguousForward = false;
+
+ /************************************
+ Interface with Moment.js
+ ************************************/
+
+ var fn = moment.fn;
+
+ moment.tz = tz;
+
+ moment.defaultZone = null;
+
+ moment.updateOffset = function (mom, keepTime) {
+ var offset;
+ if (mom._z === undefined) {
+ mom._z = moment.defaultZone;
+ }
+ if (mom._z) {
+ offset = mom._z.offset(mom);
+ if (Math.abs(offset) < 16) {
+ offset = offset / 60;
+ }
+ if (mom.utcOffset !== undefined) {
+ mom.utcOffset(-offset, keepTime);
+ } else {
+ mom.zone(offset, keepTime);
+ }
+ }
+ };
+
+ fn.tz = function (name) {
+ if (name) {
+ this._z = getZone(name);
+ if (this._z) {
+ moment.updateOffset(this);
+ } else {
+ logError("Moment Timezone has no data for " + name + ". See http://momentjs.com/timezone/docs/#/data-loading/.");
+ }
+ return this;
+ }
+ if (this._z) { return this._z.name; }
+ };
+
+ function abbrWrap (old) {
+ return function () {
+ if (this._z) { return this._z.abbr(this); }
+ return old.call(this);
+ };
+ }
+
+ function resetZoneWrap (old) {
+ return function () {
+ this._z = null;
+ return old.apply(this, arguments);
+ };
+ }
+
+ fn.zoneName = abbrWrap(fn.zoneName);
+ fn.zoneAbbr = abbrWrap(fn.zoneAbbr);
+ fn.utc = resetZoneWrap(fn.utc);
+
+ moment.tz.setDefault = function(name) {
+ if (major < 2 || (major === 2 && minor < 9)) {
+ logError('Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js ' + moment.version + '.');
+ }
+ moment.defaultZone = name ? getZone(name) : null;
+ return moment;
+ };
+
+ // Cloning a moment should include the _z property.
+ var momentProperties = moment.momentProperties;
+ if (Object.prototype.toString.call(momentProperties) === '[object Array]') {
+ // moment 2.8.1+
+ momentProperties.push('_z');
+ momentProperties.push('_a');
+ } else if (momentProperties) {
+ // moment 2.7.0
+ momentProperties._z = null;
+ }
+
+ loadData({
+ "version": "2014j",
+ "zones": [
+ "Africa/Abidjan|GMT|0|0|",
+ "Africa/Addis_Ababa|EAT|-30|0|",
+ "Africa/Algiers|CET|-10|0|",
+ "Africa/Bangui|WAT|-10|0|",
+ "Africa/Blantyre|CAT|-20|0|",
+ "Africa/Cairo|EET EEST|-20 -30|0101010101010101010101010101010|1Cby0 Fb0 c10 8n0 8Nd0 gL0 e10 mn0 1o10 jz0 gN0 pb0 1qN0 dX0 e10 xz0 1o10 bb0 e10 An0 1o10 5z0 e10 FX0 1o10 2L0 e10 IL0 1C10 Lz0",
+ "Africa/Casablanca|WET WEST|0 -10|01010101010101010101010101010101010101010|1Cco0 Db0 1zd0 Lz0 1Nf0 wM0 co0 go0 1o00 s00 dA0 vc0 11A0 A00 e00 y00 11A0 uo0 e00 DA0 11A0 rA0 e00 Jc0 WM0 m00 gM0 M00 WM0 jc0 e00 RA0 11A0 dA0 e00 Uo0 11A0 800 gM0 Xc0",
+ "Africa/Ceuta|CET CEST|-10 -20|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "Africa/Johannesburg|SAST|-20|0|",
+ "Africa/Tripoli|EET CET CEST|-20 -10 -20|0120|1IlA0 TA0 1o00",
+ "Africa/Windhoek|WAST WAT|-20 -10|01010101010101010101010|1C1c0 11B0 1nX0 11B0 1nX0 11B0 1qL0 WN0 1qL0 11B0 1nX0 11B0 1nX0 11B0 1nX0 11B0 1nX0 11B0 1qL0 WN0 1qL0 11B0",
+ "America/Adak|HAST HADT|a0 90|01010101010101010101010|1BR00 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Anchorage|AKST AKDT|90 80|01010101010101010101010|1BQX0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Anguilla|AST|40|0|",
+ "America/Araguaina|BRT BRST|30 20|010|1IdD0 Lz0",
+ "America/Argentina/Buenos_Aires|ART|30|0|",
+ "America/Asuncion|PYST PYT|30 40|01010101010101010101010|1C430 1a10 1fz0 1a10 1fz0 1cN0 17b0 1ip0 17b0 1ip0 17b0 1ip0 19X0 1fB0 19X0 1fB0 19X0 1ip0 17b0 1ip0 17b0 1ip0",
+ "America/Atikokan|EST|50|0|",
+ "America/Bahia|BRT BRST|30 20|010|1FJf0 Rb0",
+ "America/Bahia_Banderas|MST CDT CST|70 50 60|01212121212121212121212|1C1l0 1nW0 11B0 1nX0 11B0 1nX0 14p0 1lb0 14p0 1lb0 14p0 1lb0 14p0 1nX0 11B0 1nX0 11B0 1nX0 14p0 1lb0 14p0 1lb0",
+ "America/Belem|BRT|30|0|",
+ "America/Belize|CST|60|0|",
+ "America/Boa_Vista|AMT|40|0|",
+ "America/Bogota|COT|50|0|",
+ "America/Boise|MST MDT|70 60|01010101010101010101010|1BQV0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Campo_Grande|AMST AMT|30 40|01010101010101010101010|1BIr0 1zd0 On0 1zd0 Rb0 1zd0 Lz0 1C10 Lz0 1C10 On0 1zd0 On0 1zd0 On0 1zd0 On0 1C10 Lz0 1C10 Lz0 1C10",
+ "America/Cancun|CST CDT|60 50|01010101010101010101010|1C1k0 1nX0 11B0 1nX0 11B0 1nX0 14p0 1lb0 14p0 1lb0 14p0 1lb0 14p0 1nX0 11B0 1nX0 11B0 1nX0 14p0 1lb0 14p0 1lb0",
+ "America/Caracas|VET|4u|0|",
+ "America/Cayenne|GFT|30|0|",
+ "America/Chicago|CST CDT|60 50|01010101010101010101010|1BQU0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Chihuahua|MST MDT|70 60|01010101010101010101010|1C1l0 1nX0 11B0 1nX0 11B0 1nX0 14p0 1lb0 14p0 1lb0 14p0 1lb0 14p0 1nX0 11B0 1nX0 11B0 1nX0 14p0 1lb0 14p0 1lb0",
+ "America/Creston|MST|70|0|",
+ "America/Dawson|PST PDT|80 70|01010101010101010101010|1BQW0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Detroit|EST EDT|50 40|01010101010101010101010|1BQT0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Eirunepe|AMT ACT|40 50|01|1KLE0",
+ "America/Glace_Bay|AST ADT|40 30|01010101010101010101010|1BQS0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Godthab|WGT WGST|30 20|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "America/Goose_Bay|AST ADT|40 30|01010101010101010101010|1BQQ1 1zb0 Op0 1zcX Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Grand_Turk|EST EDT AST|50 40 40|0101010101012|1BQT0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Guayaquil|ECT|50|0|",
+ "America/Guyana|GYT|40|0|",
+ "America/Havana|CST CDT|50 40|01010101010101010101010|1BQR0 1wo0 U00 1zc0 U00 1qM0 Oo0 1zc0 Oo0 1zc0 Oo0 1zc0 Rc0 1zc0 Oo0 1zc0 Oo0 1zc0 Oo0 1zc0 Oo0 1zc0",
+ "America/La_Paz|BOT|40|0|",
+ "America/Lima|PET|50|0|",
+ "America/Metlakatla|PST|80|0|",
+ "America/Miquelon|PMST PMDT|30 20|01010101010101010101010|1BQR0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Montevideo|UYST UYT|20 30|01010101010101010101010|1BQQ0 1ld0 14n0 1ld0 14n0 1o10 11z0 1o10 11z0 1o10 11z0 1o10 14n0 1ld0 14n0 1ld0 14n0 1o10 11z0 1o10 11z0 1o10",
+ "America/Noronha|FNT|20|0|",
+ "America/North_Dakota/Beulah|MST MDT CST CDT|70 60 60 50|01232323232323232323232|1BQV0 1zb0 Oo0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Paramaribo|SRT|30|0|",
+ "America/Port-au-Prince|EST EDT|50 40|0101010101010101010|1GI70 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "America/Santa_Isabel|PST PDT|80 70|01010101010101010101010|1C1m0 1nX0 11B0 1nX0 11B0 1nX0 14p0 1lb0 14p0 1lb0 14p0 1lb0 14p0 1nX0 11B0 1nX0 11B0 1nX0 14p0 1lb0 14p0 1lb0",
+ "America/Santiago|CLST CLT|30 40|01010101010101010101010|1C1f0 1fB0 1nX0 G10 1EL0 Op0 1zb0 Rd0 1wn0 Rd0 1wn0 Rd0 1wn0 Rd0 1wn0 Rd0 1zb0 Op0 1zb0 Rd0 1wn0 Rd0",
+ "America/Sao_Paulo|BRST BRT|20 30|01010101010101010101010|1BIq0 1zd0 On0 1zd0 Rb0 1zd0 Lz0 1C10 Lz0 1C10 On0 1zd0 On0 1zd0 On0 1zd0 On0 1C10 Lz0 1C10 Lz0 1C10",
+ "America/Scoresbysund|EGT EGST|10 0|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "America/St_Johns|NST NDT|3u 2u|01010101010101010101010|1BQPv 1zb0 Op0 1zcX Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Rd0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0 Op0 1zb0",
+ "Antarctica/Casey|CAST AWST|-b0 -80|0101|1BN30 40P0 KL0",
+ "Antarctica/Davis|DAVT DAVT|-50 -70|0101|1BPw0 3Wn0 KN0",
+ "Antarctica/DumontDUrville|DDUT|-a0|0|",
+ "Antarctica/Macquarie|AEDT MIST|-b0 -b0|01|1C140",
+ "Antarctica/Mawson|MAWT|-50|0|",
+ "Antarctica/McMurdo|NZDT NZST|-d0 -c0|01010101010101010101010|1C120 1a00 1fA0 1a00 1fA0 1cM0 1fA0 1a00 1fA0 1a00 1fA0 1a00 1fA0 1a00 1fA0 1a00 1fA0 1cM0 1fA0 1a00 1fA0 1a00",
+ "Antarctica/Rothera|ROTT|30|0|",
+ "Antarctica/Syowa|SYOT|-30|0|",
+ "Antarctica/Troll|UTC CEST|0 -20|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "Antarctica/Vostok|VOST|-60|0|",
+ "Asia/Aden|AST|-30|0|",
+ "Asia/Almaty|ALMT|-60|0|",
+ "Asia/Amman|EET EEST|-20 -30|010101010101010101010|1BVy0 1qM0 11A0 1o00 11A0 4bX0 Dd0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0",
+ "Asia/Anadyr|ANAT ANAST ANAT|-c0 -c0 -b0|0120|1BWe0 1qN0 WM0",
+ "Asia/Aqtau|AQTT|-50|0|",
+ "Asia/Ashgabat|TMT|-50|0|",
+ "Asia/Baku|AZT AZST|-40 -50|01010101010101010101010|1BWo0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "Asia/Bangkok|ICT|-70|0|",
+ "Asia/Beirut|EET EEST|-20 -30|01010101010101010101010|1BWm0 1qL0 WN0 1qL0 WN0 1qL0 11B0 1nX0 11B0 1nX0 11B0 1nX0 11B0 1qL0 WN0 1qL0 WN0 1qL0 11B0 1nX0 11B0 1nX0",
+ "Asia/Bishkek|KGT|-60|0|",
+ "Asia/Brunei|BNT|-80|0|",
+ "Asia/Calcutta|IST|-5u|0|",
+ "Asia/Chita|YAKT YAKST YAKT IRKT|-90 -a0 -a0 -80|01023|1BWh0 1qM0 WM0 8Hz0",
+ "Asia/Choibalsan|CHOT|-80|0|",
+ "Asia/Chongqing|CST|-80|0|",
+ "Asia/Dacca|BDT|-60|0|",
+ "Asia/Damascus|EET EEST|-20 -30|01010101010101010101010|1C0m0 1nX0 11B0 1nX0 11B0 1nX0 11B0 1nX0 11B0 1qL0 WN0 1qL0 WN0 1qL0 11B0 1nX0 11B0 1nX0 11B0 1nX0 11B0 1qL0",
+ "Asia/Dili|TLT|-90|0|",
+ "Asia/Dubai|GST|-40|0|",
+ "Asia/Dushanbe|TJT|-50|0|",
+ "Asia/Gaza|EET EEST|-20 -30|01010101010101010101010|1BVW1 SKX 1xd1 MKX 1AN0 1a00 1fA0 1cL0 1cN0 1cL0 1cN0 1cL0 1fB0 19X0 1fB0 19X0 1fB0 19X0 1fB0 1cL0 1cN0 1cL0",
+ "Asia/Hebron|EET EEST|-20 -30|0101010101010101010101010|1BVy0 Tb0 1xd1 MKX bB0 cn0 1cN0 1a00 1fA0 1cL0 1cN0 1cL0 1cN0 1cL0 1fB0 19X0 1fB0 19X0 1fB0 19X0 1fB0 1cL0 1cN0 1cL0",
+ "Asia/Hong_Kong|HKT|-80|0|",
+ "Asia/Hovd|HOVT|-70|0|",
+ "Asia/Irkutsk|IRKT IRKST IRKT|-80 -90 -90|01020|1BWi0 1qM0 WM0 8Hz0",
+ "Asia/Istanbul|EET EEST|-20 -30|01010101010101010101010|1BWp0 1qM0 Xc0 1qo0 WM0 1qM0 11A0 1o00 1200 1nA0 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "Asia/Jakarta|WIB|-70|0|",
+ "Asia/Jayapura|WIT|-90|0|",
+ "Asia/Jerusalem|IST IDT|-20 -30|01010101010101010101010|1BVA0 17X0 1kp0 1dz0 1c10 1aL0 1eN0 1oL0 10N0 1oL0 10N0 1oL0 10N0 1rz0 W10 1rz0 W10 1rz0 10N0 1oL0 10N0 1oL0",
+ "Asia/Kabul|AFT|-4u|0|",
+ "Asia/Kamchatka|PETT PETST PETT|-c0 -c0 -b0|0120|1BWe0 1qN0 WM0",
+ "Asia/Karachi|PKT|-50|0|",
+ "Asia/Kashgar|XJT|-60|0|",
+ "Asia/Kathmandu|NPT|-5J|0|",
+ "Asia/Khandyga|VLAT VLAST VLAT YAKT YAKT|-a0 -b0 -b0 -a0 -90|010234|1BWg0 1qM0 WM0 17V0 7zD0",
+ "Asia/Krasnoyarsk|KRAT KRAST KRAT|-70 -80 -80|01020|1BWj0 1qM0 WM0 8Hz0",
+ "Asia/Kuala_Lumpur|MYT|-80|0|",
+ "Asia/Magadan|MAGT MAGST MAGT MAGT|-b0 -c0 -c0 -a0|01023|1BWf0 1qM0 WM0 8Hz0",
+ "Asia/Makassar|WITA|-80|0|",
+ "Asia/Manila|PHT|-80|0|",
+ "Asia/Nicosia|EET EEST|-20 -30|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "Asia/Novokuznetsk|KRAT NOVST NOVT NOVT|-70 -70 -60 -70|01230|1BWj0 1qN0 WM0 8Hz0",
+ "Asia/Novosibirsk|NOVT NOVST NOVT|-60 -70 -70|01020|1BWk0 1qM0 WM0 8Hz0",
+ "Asia/Omsk|OMST OMSST OMST|-60 -70 -70|01020|1BWk0 1qM0 WM0 8Hz0",
+ "Asia/Oral|ORAT|-50|0|",
+ "Asia/Pyongyang|KST|-90|0|",
+ "Asia/Qyzylorda|QYZT|-60|0|",
+ "Asia/Rangoon|MMT|-6u|0|",
+ "Asia/Sakhalin|SAKT SAKST SAKT|-a0 -b0 -b0|01020|1BWg0 1qM0 WM0 8Hz0",
+ "Asia/Samarkand|UZT|-50|0|",
+ "Asia/Singapore|SGT|-80|0|",
+ "Asia/Srednekolymsk|MAGT MAGST MAGT SRET|-b0 -c0 -c0 -b0|01023|1BWf0 1qM0 WM0 8Hz0",
+ "Asia/Tbilisi|GET|-40|0|",
+ "Asia/Tehran|IRST IRDT|-3u -4u|01010101010101010101010|1BTUu 1dz0 1cp0 1dz0 1cp0 1dz0 1cN0 1dz0 1cp0 1dz0 1cp0 1dz0 1cp0 1dz0 1cN0 1dz0 1cp0 1dz0 1cp0 1dz0 1cp0 1dz0",
+ "Asia/Thimbu|BTT|-60|0|",
+ "Asia/Tokyo|JST|-90|0|",
+ "Asia/Ulaanbaatar|ULAT|-80|0|",
+ "Asia/Ust-Nera|MAGT MAGST MAGT VLAT VLAT|-b0 -c0 -c0 -b0 -a0|010234|1BWf0 1qM0 WM0 17V0 7zD0",
+ "Asia/Vladivostok|VLAT VLAST VLAT|-a0 -b0 -b0|01020|1BWg0 1qM0 WM0 8Hz0",
+ "Asia/Yakutsk|YAKT YAKST YAKT|-90 -a0 -a0|01020|1BWh0 1qM0 WM0 8Hz0",
+ "Asia/Yekaterinburg|YEKT YEKST YEKT|-50 -60 -60|01020|1BWl0 1qM0 WM0 8Hz0",
+ "Asia/Yerevan|AMT AMST|-40 -50|01010|1BWm0 1qM0 WM0 1qM0",
+ "Atlantic/Azores|AZOT AZOST|10 0|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "Atlantic/Canary|WET WEST|0 -10|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "Atlantic/Cape_Verde|CVT|10|0|",
+ "Atlantic/South_Georgia|GST|20|0|",
+ "Atlantic/Stanley|FKST FKT|30 40|010|1C6R0 U10",
+ "Australia/ACT|AEDT AEST|-b0 -a0|01010101010101010101010|1C140 1cM0 1cM0 1cM0 1cM0 1fA0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1fA0 1cM0 1cM0 1cM0 1cM0",
+ "Australia/Adelaide|ACDT ACST|-au -9u|01010101010101010101010|1C14u 1cM0 1cM0 1cM0 1cM0 1fA0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1fA0 1cM0 1cM0 1cM0 1cM0",
+ "Australia/Brisbane|AEST|-a0|0|",
+ "Australia/Darwin|ACST|-9u|0|",
+ "Australia/Eucla|ACWST|-8J|0|",
+ "Australia/LHI|LHDT LHST|-b0 -au|01010101010101010101010|1C130 1cMu 1cLu 1cMu 1cLu 1fAu 1cLu 1cMu 1cLu 1cMu 1cLu 1cMu 1cLu 1cMu 1cLu 1cMu 1cLu 1fAu 1cLu 1cMu 1cLu 1cMu",
+ "Australia/Perth|AWST|-80|0|",
+ "Chile/EasterIsland|EASST EAST|50 60|01010101010101010101010|1C1f0 1fB0 1nX0 G10 1EL0 Op0 1zb0 Rd0 1wn0 Rd0 1wn0 Rd0 1wn0 Rd0 1wn0 Rd0 1zb0 Op0 1zb0 Rd0 1wn0 Rd0",
+ "Eire|GMT IST|0 -10|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "Etc/GMT+1|GMT+1|10|0|",
+ "Etc/GMT+10|GMT+10|a0|0|",
+ "Etc/GMT+11|GMT+11|b0|0|",
+ "Etc/GMT+12|GMT+12|c0|0|",
+ "Etc/GMT+2|GMT+2|20|0|",
+ "Etc/GMT+3|GMT+3|30|0|",
+ "Etc/GMT+4|GMT+4|40|0|",
+ "Etc/GMT+5|GMT+5|50|0|",
+ "Etc/GMT+6|GMT+6|60|0|",
+ "Etc/GMT+7|GMT+7|70|0|",
+ "Etc/GMT+8|GMT+8|80|0|",
+ "Etc/GMT+9|GMT+9|90|0|",
+ "Etc/GMT-1|GMT-1|-10|0|",
+ "Etc/GMT-10|GMT-10|-a0|0|",
+ "Etc/GMT-11|GMT-11|-b0|0|",
+ "Etc/GMT-12|GMT-12|-c0|0|",
+ "Etc/GMT-13|GMT-13|-d0|0|",
+ "Etc/GMT-14|GMT-14|-e0|0|",
+ "Etc/GMT-2|GMT-2|-20|0|",
+ "Etc/GMT-3|GMT-3|-30|0|",
+ "Etc/GMT-4|GMT-4|-40|0|",
+ "Etc/GMT-5|GMT-5|-50|0|",
+ "Etc/GMT-6|GMT-6|-60|0|",
+ "Etc/GMT-7|GMT-7|-70|0|",
+ "Etc/GMT-8|GMT-8|-80|0|",
+ "Etc/GMT-9|GMT-9|-90|0|",
+ "Etc/UCT|UCT|0|0|",
+ "Etc/UTC|UTC|0|0|",
+ "Europe/Belfast|GMT BST|0 -10|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "Europe/Kaliningrad|EET EEST FET|-20 -30 -30|01020|1BWo0 1qM0 WM0 8Hz0",
+ "Europe/Minsk|EET EEST FET MSK|-20 -30 -30 -30|01023|1BWo0 1qM0 WM0 8Hy0",
+ "Europe/Moscow|MSK MSD MSK|-30 -40 -40|01020|1BWn0 1qM0 WM0 8Hz0",
+ "Europe/Samara|SAMT SAMST SAMT|-40 -40 -30|0120|1BWm0 1qN0 WM0",
+ "Europe/Simferopol|EET EEST MSK MSK|-20 -30 -40 -30|01010101023|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11z0 1nW0",
+ "Europe/Volgograd|MSK MSK|-30 -40|01010|1BWn0 1qM0 WM0 8Hz0",
+ "HST|HST|a0|0|",
+ "Indian/Chagos|IOT|-60|0|",
+ "Indian/Christmas|CXT|-70|0|",
+ "Indian/Cocos|CCT|-6u|0|",
+ "Indian/Kerguelen|TFT|-50|0|",
+ "Indian/Mahe|SCT|-40|0|",
+ "Indian/Maldives|MVT|-50|0|",
+ "Indian/Mauritius|MUT|-40|0|",
+ "Indian/Reunion|RET|-40|0|",
+ "Kwajalein|MHT|-c0|0|",
+ "MET|MET MEST|-10 -20|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00",
+ "NZ-CHAT|CHADT CHAST|-dJ -cJ|01010101010101010101010|1C120 1a00 1fA0 1a00 1fA0 1cM0 1fA0 1a00 1fA0 1a00 1fA0 1a00 1fA0 1a00 1fA0 1a00 1fA0 1cM0 1fA0 1a00 1fA0 1a00",
+ "Pacific/Apia|SST SDT WSDT WSST|b0 a0 -e0 -d0|01012323232323232323232|1Dbn0 1ff0 1a00 CI0 AQ0 1cM0 1fA0 1a00 1fA0 1a00 1fA0 1a00 1fA0 1a00 1fA0 1a00 1fA0 1cM0 1fA0 1a00 1fA0 1a00",
+ "Pacific/Bougainville|PGT BST|-a0 -b0|01|1NwE0",
+ "Pacific/Chuuk|CHUT|-a0|0|",
+ "Pacific/Efate|VUT|-b0|0|",
+ "Pacific/Enderbury|PHOT|-d0|0|",
+ "Pacific/Fakaofo|TKT TKT|b0 -d0|01|1Gfn0",
+ "Pacific/Fiji|FJST FJT|-d0 -c0|01010101010101010101010|1BWe0 1o00 Rc0 1wo0 Ao0 1Nc0 Ao0 1Q00 xz0 1SN0 uM0 1SM0 xA0 1SM0 uM0 1SM0 uM0 1SM0 uM0 1SM0 uM0 1SM0",
+ "Pacific/Funafuti|TVT|-c0|0|",
+ "Pacific/Galapagos|GALT|60|0|",
+ "Pacific/Gambier|GAMT|90|0|",
+ "Pacific/Guadalcanal|SBT|-b0|0|",
+ "Pacific/Guam|ChST|-a0|0|",
+ "Pacific/Kiritimati|LINT|-e0|0|",
+ "Pacific/Kosrae|KOST|-b0|0|",
+ "Pacific/Marquesas|MART|9u|0|",
+ "Pacific/Midway|SST|b0|0|",
+ "Pacific/Nauru|NRT|-c0|0|",
+ "Pacific/Niue|NUT|b0|0|",
+ "Pacific/Norfolk|NFT|-bu|0|",
+ "Pacific/Noumea|NCT|-b0|0|",
+ "Pacific/Palau|PWT|-90|0|",
+ "Pacific/Pohnpei|PONT|-b0|0|",
+ "Pacific/Port_Moresby|PGT|-a0|0|",
+ "Pacific/Rarotonga|CKT|a0|0|",
+ "Pacific/Tahiti|TAHT|a0|0|",
+ "Pacific/Tarawa|GILT|-c0|0|",
+ "Pacific/Tongatapu|TOT|-d0|0|",
+ "Pacific/Wake|WAKT|-c0|0|",
+ "Pacific/Wallis|WFT|-c0|0|"
+ ],
+ "links": [
+ "Africa/Abidjan|Africa/Accra",
+ "Africa/Abidjan|Africa/Bamako",
+ "Africa/Abidjan|Africa/Banjul",
+ "Africa/Abidjan|Africa/Bissau",
+ "Africa/Abidjan|Africa/Conakry",
+ "Africa/Abidjan|Africa/Dakar",
+ "Africa/Abidjan|Africa/Freetown",
+ "Africa/Abidjan|Africa/Lome",
+ "Africa/Abidjan|Africa/Monrovia",
+ "Africa/Abidjan|Africa/Nouakchott",
+ "Africa/Abidjan|Africa/Ouagadougou",
+ "Africa/Abidjan|Africa/Sao_Tome",
+ "Africa/Abidjan|Africa/Timbuktu",
+ "Africa/Abidjan|America/Danmarkshavn",
+ "Africa/Abidjan|Atlantic/Reykjavik",
+ "Africa/Abidjan|Atlantic/St_Helena",
+ "Africa/Abidjan|Etc/GMT",
+ "Africa/Abidjan|Etc/GMT+0",
+ "Africa/Abidjan|Etc/GMT-0",
+ "Africa/Abidjan|Etc/GMT0",
+ "Africa/Abidjan|Etc/Greenwich",
+ "Africa/Abidjan|GMT",
+ "Africa/Abidjan|GMT+0",
+ "Africa/Abidjan|GMT-0",
+ "Africa/Abidjan|GMT0",
+ "Africa/Abidjan|Greenwich",
+ "Africa/Abidjan|Iceland",
+ "Africa/Addis_Ababa|Africa/Asmara",
+ "Africa/Addis_Ababa|Africa/Asmera",
+ "Africa/Addis_Ababa|Africa/Dar_es_Salaam",
+ "Africa/Addis_Ababa|Africa/Djibouti",
+ "Africa/Addis_Ababa|Africa/Juba",
+ "Africa/Addis_Ababa|Africa/Kampala",
+ "Africa/Addis_Ababa|Africa/Khartoum",
+ "Africa/Addis_Ababa|Africa/Mogadishu",
+ "Africa/Addis_Ababa|Africa/Nairobi",
+ "Africa/Addis_Ababa|Indian/Antananarivo",
+ "Africa/Addis_Ababa|Indian/Comoro",
+ "Africa/Addis_Ababa|Indian/Mayotte",
+ "Africa/Algiers|Africa/Tunis",
+ "Africa/Bangui|Africa/Brazzaville",
+ "Africa/Bangui|Africa/Douala",
+ "Africa/Bangui|Africa/Kinshasa",
+ "Africa/Bangui|Africa/Lagos",
+ "Africa/Bangui|Africa/Libreville",
+ "Africa/Bangui|Africa/Luanda",
+ "Africa/Bangui|Africa/Malabo",
+ "Africa/Bangui|Africa/Ndjamena",
+ "Africa/Bangui|Africa/Niamey",
+ "Africa/Bangui|Africa/Porto-Novo",
+ "Africa/Blantyre|Africa/Bujumbura",
+ "Africa/Blantyre|Africa/Gaborone",
+ "Africa/Blantyre|Africa/Harare",
+ "Africa/Blantyre|Africa/Kigali",
+ "Africa/Blantyre|Africa/Lubumbashi",
+ "Africa/Blantyre|Africa/Lusaka",
+ "Africa/Blantyre|Africa/Maputo",
+ "Africa/Cairo|Egypt",
+ "Africa/Casablanca|Africa/El_Aaiun",
+ "Africa/Ceuta|Arctic/Longyearbyen",
+ "Africa/Ceuta|Atlantic/Jan_Mayen",
+ "Africa/Ceuta|CET",
+ "Africa/Ceuta|Europe/Amsterdam",
+ "Africa/Ceuta|Europe/Andorra",
+ "Africa/Ceuta|Europe/Belgrade",
+ "Africa/Ceuta|Europe/Berlin",
+ "Africa/Ceuta|Europe/Bratislava",
+ "Africa/Ceuta|Europe/Brussels",
+ "Africa/Ceuta|Europe/Budapest",
+ "Africa/Ceuta|Europe/Busingen",
+ "Africa/Ceuta|Europe/Copenhagen",
+ "Africa/Ceuta|Europe/Gibraltar",
+ "Africa/Ceuta|Europe/Ljubljana",
+ "Africa/Ceuta|Europe/Luxembourg",
+ "Africa/Ceuta|Europe/Madrid",
+ "Africa/Ceuta|Europe/Malta",
+ "Africa/Ceuta|Europe/Monaco",
+ "Africa/Ceuta|Europe/Oslo",
+ "Africa/Ceuta|Europe/Paris",
+ "Africa/Ceuta|Europe/Podgorica",
+ "Africa/Ceuta|Europe/Prague",
+ "Africa/Ceuta|Europe/Rome",
+ "Africa/Ceuta|Europe/San_Marino",
+ "Africa/Ceuta|Europe/Sarajevo",
+ "Africa/Ceuta|Europe/Skopje",
+ "Africa/Ceuta|Europe/Stockholm",
+ "Africa/Ceuta|Europe/Tirane",
+ "Africa/Ceuta|Europe/Vaduz",
+ "Africa/Ceuta|Europe/Vatican",
+ "Africa/Ceuta|Europe/Vienna",
+ "Africa/Ceuta|Europe/Warsaw",
+ "Africa/Ceuta|Europe/Zagreb",
+ "Africa/Ceuta|Europe/Zurich",
+ "Africa/Ceuta|Poland",
+ "Africa/Johannesburg|Africa/Maseru",
+ "Africa/Johannesburg|Africa/Mbabane",
+ "Africa/Tripoli|Libya",
+ "America/Adak|America/Atka",
+ "America/Adak|US/Aleutian",
+ "America/Anchorage|America/Juneau",
+ "America/Anchorage|America/Nome",
+ "America/Anchorage|America/Sitka",
+ "America/Anchorage|America/Yakutat",
+ "America/Anchorage|US/Alaska",
+ "America/Anguilla|America/Antigua",
+ "America/Anguilla|America/Aruba",
+ "America/Anguilla|America/Barbados",
+ "America/Anguilla|America/Blanc-Sablon",
+ "America/Anguilla|America/Curacao",
+ "America/Anguilla|America/Dominica",
+ "America/Anguilla|America/Grenada",
+ "America/Anguilla|America/Guadeloupe",
+ "America/Anguilla|America/Kralendijk",
+ "America/Anguilla|America/Lower_Princes",
+ "America/Anguilla|America/Marigot",
+ "America/Anguilla|America/Martinique",
+ "America/Anguilla|America/Montserrat",
+ "America/Anguilla|America/Port_of_Spain",
+ "America/Anguilla|America/Puerto_Rico",
+ "America/Anguilla|America/Santo_Domingo",
+ "America/Anguilla|America/St_Barthelemy",
+ "America/Anguilla|America/St_Kitts",
+ "America/Anguilla|America/St_Lucia",
+ "America/Anguilla|America/St_Thomas",
+ "America/Anguilla|America/St_Vincent",
+ "America/Anguilla|America/Tortola",
+ "America/Anguilla|America/Virgin",
+ "America/Argentina/Buenos_Aires|America/Argentina/Catamarca",
+ "America/Argentina/Buenos_Aires|America/Argentina/ComodRivadavia",
+ "America/Argentina/Buenos_Aires|America/Argentina/Cordoba",
+ "America/Argentina/Buenos_Aires|America/Argentina/Jujuy",
+ "America/Argentina/Buenos_Aires|America/Argentina/La_Rioja",
+ "America/Argentina/Buenos_Aires|America/Argentina/Mendoza",
+ "America/Argentina/Buenos_Aires|America/Argentina/Rio_Gallegos",
+ "America/Argentina/Buenos_Aires|America/Argentina/Salta",
+ "America/Argentina/Buenos_Aires|America/Argentina/San_Juan",
+ "America/Argentina/Buenos_Aires|America/Argentina/San_Luis",
+ "America/Argentina/Buenos_Aires|America/Argentina/Tucuman",
+ "America/Argentina/Buenos_Aires|America/Argentina/Ushuaia",
+ "America/Argentina/Buenos_Aires|America/Buenos_Aires",
+ "America/Argentina/Buenos_Aires|America/Catamarca",
+ "America/Argentina/Buenos_Aires|America/Cordoba",
+ "America/Argentina/Buenos_Aires|America/Jujuy",
+ "America/Argentina/Buenos_Aires|America/Mendoza",
+ "America/Argentina/Buenos_Aires|America/Rosario",
+ "America/Atikokan|America/Cayman",
+ "America/Atikokan|America/Coral_Harbour",
+ "America/Atikokan|America/Jamaica",
+ "America/Atikokan|America/Panama",
+ "America/Atikokan|EST",
+ "America/Atikokan|Jamaica",
+ "America/Belem|America/Fortaleza",
+ "America/Belem|America/Maceio",
+ "America/Belem|America/Recife",
+ "America/Belem|America/Santarem",
+ "America/Belize|America/Costa_Rica",
+ "America/Belize|America/El_Salvador",
+ "America/Belize|America/Guatemala",
+ "America/Belize|America/Managua",
+ "America/Belize|America/Regina",
+ "America/Belize|America/Swift_Current",
+ "America/Belize|America/Tegucigalpa",
+ "America/Belize|Canada/East-Saskatchewan",
+ "America/Belize|Canada/Saskatchewan",
+ "America/Boa_Vista|America/Manaus",
+ "America/Boa_Vista|America/Porto_Velho",
+ "America/Boa_Vista|Brazil/West",
+ "America/Boise|America/Cambridge_Bay",
+ "America/Boise|America/Denver",
+ "America/Boise|America/Edmonton",
+ "America/Boise|America/Inuvik",
+ "America/Boise|America/Ojinaga",
+ "America/Boise|America/Shiprock",
+ "America/Boise|America/Yellowknife",
+ "America/Boise|Canada/Mountain",
+ "America/Boise|MST7MDT",
+ "America/Boise|Navajo",
+ "America/Boise|US/Mountain",
+ "America/Campo_Grande|America/Cuiaba",
+ "America/Cancun|America/Merida",
+ "America/Cancun|America/Mexico_City",
+ "America/Cancun|America/Monterrey",
+ "America/Cancun|Mexico/General",
+ "America/Chicago|America/Indiana/Knox",
+ "America/Chicago|America/Indiana/Tell_City",
+ "America/Chicago|America/Knox_IN",
+ "America/Chicago|America/Matamoros",
+ "America/Chicago|America/Menominee",
+ "America/Chicago|America/North_Dakota/Center",
+ "America/Chicago|America/North_Dakota/New_Salem",
+ "America/Chicago|America/Rainy_River",
+ "America/Chicago|America/Rankin_Inlet",
+ "America/Chicago|America/Resolute",
+ "America/Chicago|America/Winnipeg",
+ "America/Chicago|CST6CDT",
+ "America/Chicago|Canada/Central",
+ "America/Chicago|US/Central",
+ "America/Chicago|US/Indiana-Starke",
+ "America/Chihuahua|America/Mazatlan",
+ "America/Chihuahua|Mexico/BajaSur",
+ "America/Creston|America/Dawson_Creek",
+ "America/Creston|America/Hermosillo",
+ "America/Creston|America/Phoenix",
+ "America/Creston|MST",
+ "America/Creston|US/Arizona",
+ "America/Dawson|America/Ensenada",
+ "America/Dawson|America/Los_Angeles",
+ "America/Dawson|America/Tijuana",
+ "America/Dawson|America/Vancouver",
+ "America/Dawson|America/Whitehorse",
+ "America/Dawson|Canada/Pacific",
+ "America/Dawson|Canada/Yukon",
+ "America/Dawson|Mexico/BajaNorte",
+ "America/Dawson|PST8PDT",
+ "America/Dawson|US/Pacific",
+ "America/Dawson|US/Pacific-New",
+ "America/Detroit|America/Fort_Wayne",
+ "America/Detroit|America/Indiana/Indianapolis",
+ "America/Detroit|America/Indiana/Marengo",
+ "America/Detroit|America/Indiana/Petersburg",
+ "America/Detroit|America/Indiana/Vevay",
+ "America/Detroit|America/Indiana/Vincennes",
+ "America/Detroit|America/Indiana/Winamac",
+ "America/Detroit|America/Indianapolis",
+ "America/Detroit|America/Iqaluit",
+ "America/Detroit|America/Kentucky/Louisville",
+ "America/Detroit|America/Kentucky/Monticello",
+ "America/Detroit|America/Louisville",
+ "America/Detroit|America/Montreal",
+ "America/Detroit|America/Nassau",
+ "America/Detroit|America/New_York",
+ "America/Detroit|America/Nipigon",
+ "America/Detroit|America/Pangnirtung",
+ "America/Detroit|America/Thunder_Bay",
+ "America/Detroit|America/Toronto",
+ "America/Detroit|Canada/Eastern",
+ "America/Detroit|EST5EDT",
+ "America/Detroit|US/East-Indiana",
+ "America/Detroit|US/Eastern",
+ "America/Detroit|US/Michigan",
+ "America/Eirunepe|America/Porto_Acre",
+ "America/Eirunepe|America/Rio_Branco",
+ "America/Eirunepe|Brazil/Acre",
+ "America/Glace_Bay|America/Halifax",
+ "America/Glace_Bay|America/Moncton",
+ "America/Glace_Bay|America/Thule",
+ "America/Glace_Bay|Atlantic/Bermuda",
+ "America/Glace_Bay|Canada/Atlantic",
+ "America/Havana|Cuba",
+ "America/Metlakatla|Pacific/Pitcairn",
+ "America/Noronha|Brazil/DeNoronha",
+ "America/Santiago|Antarctica/Palmer",
+ "America/Santiago|Chile/Continental",
+ "America/Sao_Paulo|Brazil/East",
+ "America/St_Johns|Canada/Newfoundland",
+ "Antarctica/McMurdo|Antarctica/South_Pole",
+ "Antarctica/McMurdo|NZ",
+ "Antarctica/McMurdo|Pacific/Auckland",
+ "Asia/Aden|Asia/Baghdad",
+ "Asia/Aden|Asia/Bahrain",
+ "Asia/Aden|Asia/Kuwait",
+ "Asia/Aden|Asia/Qatar",
+ "Asia/Aden|Asia/Riyadh",
+ "Asia/Aqtau|Asia/Aqtobe",
+ "Asia/Ashgabat|Asia/Ashkhabad",
+ "Asia/Bangkok|Asia/Ho_Chi_Minh",
+ "Asia/Bangkok|Asia/Phnom_Penh",
+ "Asia/Bangkok|Asia/Saigon",
+ "Asia/Bangkok|Asia/Vientiane",
+ "Asia/Calcutta|Asia/Colombo",
+ "Asia/Calcutta|Asia/Kolkata",
+ "Asia/Chongqing|Asia/Chungking",
+ "Asia/Chongqing|Asia/Harbin",
+ "Asia/Chongqing|Asia/Macao",
+ "Asia/Chongqing|Asia/Macau",
+ "Asia/Chongqing|Asia/Shanghai",
+ "Asia/Chongqing|Asia/Taipei",
+ "Asia/Chongqing|PRC",
+ "Asia/Chongqing|ROC",
+ "Asia/Dacca|Asia/Dhaka",
+ "Asia/Dubai|Asia/Muscat",
+ "Asia/Hong_Kong|Hongkong",
+ "Asia/Istanbul|Europe/Istanbul",
+ "Asia/Istanbul|Turkey",
+ "Asia/Jakarta|Asia/Pontianak",
+ "Asia/Jerusalem|Asia/Tel_Aviv",
+ "Asia/Jerusalem|Israel",
+ "Asia/Kashgar|Asia/Urumqi",
+ "Asia/Kathmandu|Asia/Katmandu",
+ "Asia/Kuala_Lumpur|Asia/Kuching",
+ "Asia/Makassar|Asia/Ujung_Pandang",
+ "Asia/Nicosia|EET",
+ "Asia/Nicosia|Europe/Athens",
+ "Asia/Nicosia|Europe/Bucharest",
+ "Asia/Nicosia|Europe/Chisinau",
+ "Asia/Nicosia|Europe/Helsinki",
+ "Asia/Nicosia|Europe/Kiev",
+ "Asia/Nicosia|Europe/Mariehamn",
+ "Asia/Nicosia|Europe/Nicosia",
+ "Asia/Nicosia|Europe/Riga",
+ "Asia/Nicosia|Europe/Sofia",
+ "Asia/Nicosia|Europe/Tallinn",
+ "Asia/Nicosia|Europe/Tiraspol",
+ "Asia/Nicosia|Europe/Uzhgorod",
+ "Asia/Nicosia|Europe/Vilnius",
+ "Asia/Nicosia|Europe/Zaporozhye",
+ "Asia/Pyongyang|Asia/Seoul",
+ "Asia/Pyongyang|ROK",
+ "Asia/Samarkand|Asia/Tashkent",
+ "Asia/Singapore|Singapore",
+ "Asia/Tehran|Iran",
+ "Asia/Thimbu|Asia/Thimphu",
+ "Asia/Tokyo|Japan",
+ "Asia/Ulaanbaatar|Asia/Ulan_Bator",
+ "Atlantic/Canary|Atlantic/Faeroe",
+ "Atlantic/Canary|Atlantic/Faroe",
+ "Atlantic/Canary|Atlantic/Madeira",
+ "Atlantic/Canary|Europe/Lisbon",
+ "Atlantic/Canary|Portugal",
+ "Atlantic/Canary|WET",
+ "Australia/ACT|Australia/Canberra",
+ "Australia/ACT|Australia/Currie",
+ "Australia/ACT|Australia/Hobart",
+ "Australia/ACT|Australia/Melbourne",
+ "Australia/ACT|Australia/NSW",
+ "Australia/ACT|Australia/Sydney",
+ "Australia/ACT|Australia/Tasmania",
+ "Australia/ACT|Australia/Victoria",
+ "Australia/Adelaide|Australia/Broken_Hill",
+ "Australia/Adelaide|Australia/South",
+ "Australia/Adelaide|Australia/Yancowinna",
+ "Australia/Brisbane|Australia/Lindeman",
+ "Australia/Brisbane|Australia/Queensland",
+ "Australia/Darwin|Australia/North",
+ "Australia/LHI|Australia/Lord_Howe",
+ "Australia/Perth|Australia/West",
+ "Chile/EasterIsland|Pacific/Easter",
+ "Eire|Europe/Dublin",
+ "Etc/UCT|UCT",
+ "Etc/UTC|Etc/Universal",
+ "Etc/UTC|Etc/Zulu",
+ "Etc/UTC|UTC",
+ "Etc/UTC|Universal",
+ "Etc/UTC|Zulu",
+ "Europe/Belfast|Europe/Guernsey",
+ "Europe/Belfast|Europe/Isle_of_Man",
+ "Europe/Belfast|Europe/Jersey",
+ "Europe/Belfast|Europe/London",
+ "Europe/Belfast|GB",
+ "Europe/Belfast|GB-Eire",
+ "Europe/Moscow|W-SU",
+ "HST|Pacific/Honolulu",
+ "HST|Pacific/Johnston",
+ "HST|US/Hawaii",
+ "Kwajalein|Pacific/Kwajalein",
+ "Kwajalein|Pacific/Majuro",
+ "NZ-CHAT|Pacific/Chatham",
+ "Pacific/Chuuk|Pacific/Truk",
+ "Pacific/Chuuk|Pacific/Yap",
+ "Pacific/Guam|Pacific/Saipan",
+ "Pacific/Midway|Pacific/Pago_Pago",
+ "Pacific/Midway|Pacific/Samoa",
+ "Pacific/Midway|US/Samoa",
+ "Pacific/Pohnpei|Pacific/Ponape"
+ ]
+ });
+
+
+ return moment;
+}));
diff --git a/app/assets/javascripts/blazer/moment.js b/app/assets/javascripts/blazer/moment.js
index b79da7f2..c635ec0b 100644
--- a/app/assets/javascripts/blazer/moment.js
+++ b/app/assets/javascripts/blazer/moment.js
@@ -1,19 +1,21 @@
//! moment.js
-//! version : 2.5.1
+//! version : 2.9.0
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
(function (undefined) {
-
/************************************
Constants
************************************/
var moment,
- VERSION = "2.5.1",
- global = this,
+ VERSION = '2.9.0',
+ // the global-scope this is NOT the global object in Node.js
+ globalScope = (typeof global !== 'undefined' && (typeof window === 'undefined' || window === global.window)) ? global : this,
+ oldGlobalMoment,
round = Math.round,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
i,
YEAR = 0,
@@ -24,24 +26,14 @@
SECOND = 5,
MILLISECOND = 6,
- // internal storage for language config files
- languages = {},
+ // internal storage for locale config files
+ locales = {},
- // moment internal properties
- momentProperties = {
- _isAMomentObject: null,
- _i : null,
- _f : null,
- _l : null,
- _strict : null,
- _isUTC : null,
- _offset : null, // optional. Combine with _isUTC
- _pf : null,
- _lang : null // optional
- },
+ // extra moment internal properties (plugins register props here)
+ momentProperties = [],
// check for nodeJS
- hasModule = (typeof module !== 'undefined' && module.exports && typeof require !== 'undefined'),
+ hasModule = (typeof module !== 'undefined' && module && module.exports),
// ASP.NET json date format regex
aspNetJsonRegex = /^\/?Date\((\-?\d+)/i,
@@ -52,8 +44,8 @@
isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,
// format tokens
- formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,
- localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,
+ formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g,
+ localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
// parsing token regexes
parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99
@@ -64,6 +56,7 @@
parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic.
parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
parseTokenT = /T/i, // T (ISO separator)
+ parseTokenOffsetMs = /[\+\-]?\d+/, // 1234567890123
parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
//strict parsing regexes
@@ -90,13 +83,13 @@
// iso time formats and regexes
isoTimes = [
- ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d{1,3}/],
+ ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
['HH:mm', /(T| )\d\d:\d\d/],
['HH', /(T| )\d\d/]
],
- // timezone chunker "+10:00" > ["10", "00"] or "-1530" > ["-15", "30"]
+ // timezone chunker '+10:00' > ['10', '00'] or '-1530' > ['-', '15', '30']
parseTimezoneChunker = /([\+\-]|\d\d)/gi,
// getter and setter names
@@ -121,6 +114,7 @@
w : 'week',
W : 'isoWeek',
M : 'month',
+ Q : 'quarter',
y : 'year',
DDD : 'dayOfYear',
e : 'weekday',
@@ -140,6 +134,15 @@
// format function strings
formatFunctions = {},
+ // default relative time thresholds
+ relativeTimeThresholds = {
+ s: 45, // seconds to minute
+ m: 45, // minutes to hour
+ h: 22, // hours to day
+ d: 26, // days to month
+ M: 11 // months to year
+ },
+
// tokens to ordinalize and pad
ordinalizeTokens = 'DDD w W M D d'.split(' '),
paddedTokens = 'M D H h m s w W'.split(' '),
@@ -149,10 +152,10 @@
return this.month() + 1;
},
MMM : function (format) {
- return this.lang().monthsShort(this, format);
+ return this.localeData().monthsShort(this, format);
},
MMMM : function (format) {
- return this.lang().months(this, format);
+ return this.localeData().months(this, format);
},
D : function () {
return this.date();
@@ -164,13 +167,13 @@
return this.day();
},
dd : function (format) {
- return this.lang().weekdaysMin(this, format);
+ return this.localeData().weekdaysMin(this, format);
},
ddd : function (format) {
- return this.lang().weekdaysShort(this, format);
+ return this.localeData().weekdaysShort(this, format);
},
dddd : function (format) {
- return this.lang().weekdays(this, format);
+ return this.localeData().weekdays(this, format);
},
w : function () {
return this.week();
@@ -216,10 +219,10 @@
return this.isoWeekday();
},
a : function () {
- return this.lang().meridiem(this.hours(), this.minutes(), true);
+ return this.localeData().meridiem(this.hours(), this.minutes(), true);
},
A : function () {
- return this.lang().meridiem(this.hours(), this.minutes(), false);
+ return this.localeData().meridiem(this.hours(), this.minutes(), false);
},
H : function () {
return this.hours();
@@ -246,20 +249,20 @@
return leftZeroFill(this.milliseconds(), 3);
},
Z : function () {
- var a = -this.zone(),
- b = "+";
+ var a = this.utcOffset(),
+ b = '+';
if (a < 0) {
a = -a;
- b = "-";
+ b = '-';
}
- return b + leftZeroFill(toInt(a / 60), 2) + ":" + leftZeroFill(toInt(a) % 60, 2);
+ return b + leftZeroFill(toInt(a / 60), 2) + ':' + leftZeroFill(toInt(a) % 60, 2);
},
ZZ : function () {
- var a = -this.zone(),
- b = "+";
+ var a = this.utcOffset(),
+ b = '+';
if (a < 0) {
a = -a;
- b = "-";
+ b = '-';
}
return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2);
},
@@ -269,6 +272,9 @@
zz : function () {
return this.zoneName();
},
+ x : function () {
+ return this.valueOf();
+ },
X : function () {
return this.unix();
},
@@ -277,7 +283,25 @@
}
},
- lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'];
+ deprecations = {},
+
+ lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'],
+
+ updateInProgress = false;
+
+ // Pick the first defined of two or three arguments. dfl comes from
+ // default.
+ function dfl(a, b, c) {
+ switch (arguments.length) {
+ case 2: return a != null ? a : b;
+ case 3: return a != null ? a : b != null ? b : c;
+ default: throw new Error('Implement me');
+ }
+ }
+
+ function hasOwnProp(a, b) {
+ return hasOwnProperty.call(a, b);
+ }
function defaultParsingFlags() {
// We need to deep clone this object, and es5 standard is not very
@@ -296,6 +320,31 @@
};
}
+ function printMsg(msg) {
+ if (moment.suppressDeprecationWarnings === false &&
+ typeof console !== 'undefined' && console.warn) {
+ console.warn('Deprecation warning: ' + msg);
+ }
+ }
+
+ function deprecate(msg, fn) {
+ var firstTime = true;
+ return extend(function () {
+ if (firstTime) {
+ printMsg(msg);
+ firstTime = false;
+ }
+ return fn.apply(this, arguments);
+ }, fn);
+ }
+
+ function deprecateSimple(name, msg) {
+ if (!deprecations[name]) {
+ printMsg(msg);
+ deprecations[name] = true;
+ }
+ }
+
function padToken(func, count) {
return function (a) {
return leftZeroFill(func.call(this, a), count);
@@ -303,10 +352,30 @@
}
function ordinalizeToken(func, period) {
return function (a) {
- return this.lang().ordinal(func.call(this, a), period);
+ return this.localeData().ordinal(func.call(this, a), period);
};
}
+ function monthDiff(a, b) {
+ // difference in months
+ var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
+ // b is in (anchor - 1 month, anchor + 1 month)
+ anchor = a.clone().add(wholeMonthDiff, 'months'),
+ anchor2, adjust;
+
+ if (b - anchor < 0) {
+ anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor - anchor2);
+ } else {
+ anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor2 - anchor);
+ }
+
+ return -(wholeMonthDiff + adjust);
+ }
+
while (ordinalizeTokens.length) {
i = ordinalizeTokens.pop();
formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i);
@@ -318,24 +387,59 @@
formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3);
+ function meridiemFixWrap(locale, hour, meridiem) {
+ var isPm;
+
+ if (meridiem == null) {
+ // nothing to do
+ return hour;
+ }
+ if (locale.meridiemHour != null) {
+ return locale.meridiemHour(hour, meridiem);
+ } else if (locale.isPM != null) {
+ // Fallback
+ isPm = locale.isPM(meridiem);
+ if (isPm && hour < 12) {
+ hour += 12;
+ }
+ if (!isPm && hour === 12) {
+ hour = 0;
+ }
+ return hour;
+ } else {
+ // thie is not supposed to happen
+ return hour;
+ }
+ }
+
/************************************
Constructors
************************************/
- function Language() {
-
+ function Locale() {
}
// Moment prototype object
- function Moment(config) {
- checkOverflow(config);
- extend(this, config);
+ function Moment(config, skipOverflow) {
+ if (skipOverflow !== false) {
+ checkOverflow(config);
+ }
+ copyConfig(this, config);
+ this._d = new Date(+config._d);
+ // Prevent infinite loop in case updateOffset creates new moment
+ // objects.
+ if (updateInProgress === false) {
+ updateInProgress = true;
+ moment.updateOffset(this);
+ updateInProgress = false;
+ }
}
// Duration Constructor
function Duration(duration) {
var normalizedInput = normalizeObjectUnits(duration),
years = normalizedInput.year || 0,
+ quarters = normalizedInput.quarter || 0,
months = normalizedInput.month || 0,
weeks = normalizedInput.week || 0,
days = normalizedInput.day || 0,
@@ -357,10 +461,13 @@
// which months you are are talking about, so we have to store
// it separately.
this._months = +months +
+ quarters * 3 +
years * 12;
this._data = {};
+ this._locale = moment.localeData();
+
this._bubble();
}
@@ -371,31 +478,67 @@
function extend(a, b) {
for (var i in b) {
- if (b.hasOwnProperty(i)) {
+ if (hasOwnProp(b, i)) {
a[i] = b[i];
}
}
- if (b.hasOwnProperty("toString")) {
+ if (hasOwnProp(b, 'toString')) {
a.toString = b.toString;
}
- if (b.hasOwnProperty("valueOf")) {
+ if (hasOwnProp(b, 'valueOf')) {
a.valueOf = b.valueOf;
}
return a;
}
- function cloneMoment(m) {
- var result = {}, i;
- for (i in m) {
- if (m.hasOwnProperty(i) && momentProperties.hasOwnProperty(i)) {
- result[i] = m[i];
+ function copyConfig(to, from) {
+ var i, prop, val;
+
+ if (typeof from._isAMomentObject !== 'undefined') {
+ to._isAMomentObject = from._isAMomentObject;
+ }
+ if (typeof from._i !== 'undefined') {
+ to._i = from._i;
+ }
+ if (typeof from._f !== 'undefined') {
+ to._f = from._f;
+ }
+ if (typeof from._l !== 'undefined') {
+ to._l = from._l;
+ }
+ if (typeof from._strict !== 'undefined') {
+ to._strict = from._strict;
+ }
+ if (typeof from._tzm !== 'undefined') {
+ to._tzm = from._tzm;
+ }
+ if (typeof from._isUTC !== 'undefined') {
+ to._isUTC = from._isUTC;
+ }
+ if (typeof from._offset !== 'undefined') {
+ to._offset = from._offset;
+ }
+ if (typeof from._pf !== 'undefined') {
+ to._pf = from._pf;
+ }
+ if (typeof from._locale !== 'undefined') {
+ to._locale = from._locale;
+ }
+
+ if (momentProperties.length > 0) {
+ for (i in momentProperties) {
+ prop = momentProperties[i];
+ val = from[prop];
+ if (typeof val !== 'undefined') {
+ to[prop] = val;
+ }
}
}
- return result;
+ return to;
}
function absRound(number) {
@@ -418,35 +561,68 @@
return (sign ? (forceSign ? '+' : '') : '-') + output;
}
- // helper function for _.addTime and _.subtractTime
- function addOrSubtractDurationFromMoment(mom, duration, isAdding, ignoreUpdateOffset) {
+ function positiveMomentsDifference(base, other) {
+ var res = {milliseconds: 0, months: 0};
+
+ res.months = other.month() - base.month() +
+ (other.year() - base.year()) * 12;
+ if (base.clone().add(res.months, 'M').isAfter(other)) {
+ --res.months;
+ }
+
+ res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
+
+ return res;
+ }
+
+ function momentsDifference(base, other) {
+ var res;
+ other = makeAs(other, base);
+ if (base.isBefore(other)) {
+ res = positiveMomentsDifference(base, other);
+ } else {
+ res = positiveMomentsDifference(other, base);
+ res.milliseconds = -res.milliseconds;
+ res.months = -res.months;
+ }
+
+ return res;
+ }
+
+ // TODO: remove 'name' arg after deprecation is removed
+ function createAdder(direction, name) {
+ return function (val, period) {
+ var dur, tmp;
+ //invert the arguments, but complain about it
+ if (period !== null && !isNaN(+period)) {
+ deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
+ tmp = val; val = period; period = tmp;
+ }
+
+ val = typeof val === 'string' ? +val : val;
+ dur = moment.duration(val, period);
+ addOrSubtractDurationFromMoment(this, dur, direction);
+ return this;
+ };
+ }
+
+ function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) {
var milliseconds = duration._milliseconds,
days = duration._days,
- months = duration._months,
- minutes,
- hours;
+ months = duration._months;
+ updateOffset = updateOffset == null ? true : updateOffset;
if (milliseconds) {
mom._d.setTime(+mom._d + milliseconds * isAdding);
}
- // store the minutes and hours so we can restore them
- if (days || months) {
- minutes = mom.minute();
- hours = mom.hour();
- }
if (days) {
- mom.date(mom.date() + days * isAdding);
+ rawSetter(mom, 'Date', rawGetter(mom, 'Date') + days * isAdding);
}
if (months) {
- mom.month(mom.month() + months * isAdding);
- }
- if (milliseconds && !ignoreUpdateOffset) {
- moment.updateOffset(mom);
+ rawMonthSetter(mom, rawGetter(mom, 'Month') + months * isAdding);
}
- // restore the minutes and hours after possibly changing dst
- if (days || months) {
- mom.minute(minutes);
- mom.hour(hours);
+ if (updateOffset) {
+ moment.updateOffset(mom, days || months);
}
}
@@ -456,8 +632,8 @@
}
function isDate(input) {
- return Object.prototype.toString.call(input) === '[object Date]' ||
- input instanceof Date;
+ return Object.prototype.toString.call(input) === '[object Date]' ||
+ input instanceof Date;
}
// compare two arrays, return the number of differences
@@ -489,7 +665,7 @@
prop;
for (prop in inputObject) {
- if (inputObject.hasOwnProperty(prop)) {
+ if (hasOwnProp(inputObject, prop)) {
normalizedProp = normalizeUnits(prop);
if (normalizedProp) {
normalizedInput[normalizedProp] = inputObject[prop];
@@ -517,7 +693,7 @@
moment[field] = function (format, index) {
var i, getter,
- method = moment.fn._lang[field],
+ method = moment._locale[field],
results = [];
if (typeof format === 'number') {
@@ -527,7 +703,7 @@
getter = function (i) {
var m = moment().utc().set(setter, i);
- return method.call(moment.fn._lang, m, format || '');
+ return method.call(moment._locale, m, format || '');
};
if (index != null) {
@@ -561,6 +737,10 @@
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
}
+ function weeksInYear(year, dow, doy) {
+ return weekOfYear(moment([year, 11, 31 + dow - doy]), dow, doy).week;
+ }
+
function daysInYear(year) {
return isLeapYear(year) ? 366 : 365;
}
@@ -575,7 +755,10 @@
overflow =
m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH :
m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE :
- m._a[HOUR] < 0 || m._a[HOUR] > 23 ? HOUR :
+ m._a[HOUR] < 0 || m._a[HOUR] > 24 ||
+ (m._a[HOUR] === 24 && (m._a[MINUTE] !== 0 ||
+ m._a[SECOND] !== 0 ||
+ m._a[MILLISECOND] !== 0)) ? HOUR :
m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE :
m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND :
m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND :
@@ -602,28 +785,80 @@
if (m._strict) {
m._isValid = m._isValid &&
m._pf.charsLeftOver === 0 &&
- m._pf.unusedTokens.length === 0;
+ m._pf.unusedTokens.length === 0 &&
+ m._pf.bigHour === undefined;
}
}
return m._isValid;
}
- function normalizeLanguage(key) {
+ function normalizeLocale(key) {
return key ? key.toLowerCase().replace('_', '-') : key;
}
- // Return a moment from input, that is local/utc/zone equivalent to model.
+ // pick the locale from the array
+ // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
+ // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
+ function chooseLocale(names) {
+ var i = 0, j, next, locale, split;
+
+ while (i < names.length) {
+ split = normalizeLocale(names[i]).split('-');
+ j = split.length;
+ next = normalizeLocale(names[i + 1]);
+ next = next ? next.split('-') : null;
+ while (j > 0) {
+ locale = loadLocale(split.slice(0, j).join('-'));
+ if (locale) {
+ return locale;
+ }
+ if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
+ //the next array item is better than a shallower substring of this one
+ break;
+ }
+ j--;
+ }
+ i++;
+ }
+ return null;
+ }
+
+ function loadLocale(name) {
+ var oldLocale = null;
+ if (!locales[name] && hasModule) {
+ try {
+ oldLocale = moment.locale();
+ require('./locale/' + name);
+ // because defineLocale currently also sets the global locale, we want to undo that for lazy loaded locales
+ moment.locale(oldLocale);
+ } catch (e) { }
+ }
+ return locales[name];
+ }
+
+ // Return a moment from input, that is local/utc/utcOffset equivalent to
+ // model.
function makeAs(input, model) {
- return model._isUTC ? moment(input).zone(model._offset || 0) :
- moment(input).local();
+ var res, diff;
+ if (model._isUTC) {
+ res = model.clone();
+ diff = (moment.isMoment(input) || isDate(input) ?
+ +input : +moment(input)) - (+res);
+ // Use low-level api, because this fn is low-level api.
+ res._d.setTime(+res._d + diff);
+ moment.updateOffset(res, false);
+ return res;
+ } else {
+ return moment(input).local();
+ }
}
/************************************
- Languages
+ Locale
************************************/
- extend(Language.prototype, {
+ extend(Locale.prototype, {
set : function (config) {
var prop, i;
@@ -635,50 +870,63 @@
this['_' + i] = prop;
}
}
+ // Lenient ordinal parsing accepts just a number in addition to
+ // number + (possibly) stuff coming from _ordinalParseLenient.
+ this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + /\d{1,2}/.source);
},
- _months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
+ _months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
months : function (m) {
return this._months[m.month()];
},
- _monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
+ _monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
monthsShort : function (m) {
return this._monthsShort[m.month()];
},
- monthsParse : function (monthName) {
+ monthsParse : function (monthName, format, strict) {
var i, mom, regex;
if (!this._monthsParse) {
this._monthsParse = [];
+ this._longMonthsParse = [];
+ this._shortMonthsParse = [];
}
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
- if (!this._monthsParse[i]) {
- mom = moment.utc([2000, i]);
+ mom = moment.utc([2000, i]);
+ if (strict && !this._longMonthsParse[i]) {
+ this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
+ this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
+ }
+ if (!strict && !this._monthsParse[i]) {
regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
}
// test the regex
- if (this._monthsParse[i].test(monthName)) {
+ if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
+ return i;
+ } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
+ return i;
+ } else if (!strict && this._monthsParse[i].test(monthName)) {
return i;
}
}
},
- _weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
+ _weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdays : function (m) {
return this._weekdays[m.day()];
},
- _weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
+ _weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysShort : function (m) {
return this._weekdaysShort[m.day()];
},
- _weekdaysMin : "Su_Mo_Tu_We_Th_Fr_Sa".split("_"),
+ _weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
weekdaysMin : function (m) {
return this._weekdaysMin[m.day()];
},
@@ -705,11 +953,12 @@
},
_longDateFormat : {
- LT : "h:mm A",
- L : "MM/DD/YYYY",
- LL : "MMMM D YYYY",
- LLL : "MMMM D YYYY LT",
- LLLL : "dddd, MMMM D YYYY LT"
+ LTS : 'h:mm:ss A',
+ LT : 'h:mm A',
+ L : 'MM/DD/YYYY',
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY LT',
+ LLLL : 'dddd, MMMM D, YYYY LT'
},
longDateFormat : function (key) {
var output = this._longDateFormat[key];
@@ -737,6 +986,7 @@
}
},
+
_calendar : {
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
@@ -745,41 +995,44 @@
lastWeek : '[Last] dddd [at] LT',
sameElse : 'L'
},
- calendar : function (key, mom) {
+ calendar : function (key, mom, now) {
var output = this._calendar[key];
- return typeof output === 'function' ? output.apply(mom) : output;
+ return typeof output === 'function' ? output.apply(mom, [now]) : output;
},
_relativeTime : {
- future : "in %s",
- past : "%s ago",
- s : "a few seconds",
- m : "a minute",
- mm : "%d minutes",
- h : "an hour",
- hh : "%d hours",
- d : "a day",
- dd : "%d days",
- M : "a month",
- MM : "%d months",
- y : "a year",
- yy : "%d years"
+ future : 'in %s',
+ past : '%s ago',
+ s : 'a few seconds',
+ m : 'a minute',
+ mm : '%d minutes',
+ h : 'an hour',
+ hh : '%d hours',
+ d : 'a day',
+ dd : '%d days',
+ M : 'a month',
+ MM : '%d months',
+ y : 'a year',
+ yy : '%d years'
},
+
relativeTime : function (number, withoutSuffix, string, isFuture) {
var output = this._relativeTime[string];
return (typeof output === 'function') ?
output(number, withoutSuffix, string, isFuture) :
output.replace(/%d/i, number);
},
+
pastFuture : function (diff, output) {
var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
},
ordinal : function (number) {
- return this._ordinal.replace("%d", number);
+ return this._ordinal.replace('%d', number);
},
- _ordinal : "%d",
+ _ordinal : '%d',
+ _ordinalParse : /\d{1,2}/,
preparse : function (string) {
return string;
@@ -798,84 +1051,20 @@
doy : 6 // The week that contains Jan 1st is the first week of the year.
},
+ firstDayOfWeek : function () {
+ return this._week.dow;
+ },
+
+ firstDayOfYear : function () {
+ return this._week.doy;
+ },
+
_invalidDate: 'Invalid date',
invalidDate: function () {
return this._invalidDate;
}
});
- // Loads a language definition into the `languages` cache. The function
- // takes a key and optionally values. If not in the browser and no values
- // are provided, it will load the language file module. As a convenience,
- // this function also returns the language values.
- function loadLang(key, values) {
- values.abbr = key;
- if (!languages[key]) {
- languages[key] = new Language();
- }
- languages[key].set(values);
- return languages[key];
- }
-
- // Remove a language from the `languages` cache. Mostly useful in tests.
- function unloadLang(key) {
- delete languages[key];
- }
-
- // Determines which language definition to use and returns it.
- //
- // With no parameters, it will return the global language. If you
- // pass in a language key, such as 'en', it will return the
- // definition for 'en', so long as 'en' has already been loaded using
- // moment.lang.
- function getLangDefinition(key) {
- var i = 0, j, lang, next, split,
- get = function (k) {
- if (!languages[k] && hasModule) {
- try {
- require('./lang/' + k);
- } catch (e) { }
- }
- return languages[k];
- };
-
- if (!key) {
- return moment.fn._lang;
- }
-
- if (!isArray(key)) {
- //short-circuit everything else
- lang = get(key);
- if (lang) {
- return lang;
- }
- key = [key];
- }
-
- //pick the language from the array
- //try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
- //substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
- while (i < key.length) {
- split = normalizeLanguage(key[i]).split('-');
- j = split.length;
- next = normalizeLanguage(key[i + 1]);
- next = next ? next.split('-') : null;
- while (j > 0) {
- lang = get(split.slice(0, j).join('-'));
- if (lang) {
- return lang;
- }
- if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
- //the next array item is better than a shallower substring of this one
- break;
- }
- j--;
- }
- i++;
- }
- return moment.fn._lang;
- }
-
/************************************
Formatting
************************************/
@@ -883,9 +1072,9 @@
function removeFormattingTokens(input) {
if (input.match(/\[[\s\S]/)) {
- return input.replace(/^\[|\]$/g, "");
+ return input.replace(/^\[|\]$/g, '');
}
- return input.replace(/\\/g, "");
+ return input.replace(/\\/g, '');
}
function makeFormatFunction(format) {
@@ -900,7 +1089,7 @@
}
return function (mom) {
- var output = "";
+ var output = '';
for (i = 0; i < length; i++) {
output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
}
@@ -910,12 +1099,11 @@
// format date using native date object
function formatMoment(m, format) {
-
if (!m.isValid()) {
- return m.lang().invalidDate();
+ return m.localeData().invalidDate();
}
- format = expandFormat(format, m.lang());
+ format = expandFormat(format, m.localeData());
if (!formatFunctions[format]) {
formatFunctions[format] = makeFormatFunction(format);
@@ -924,11 +1112,11 @@
return formatFunctions[format](m);
}
- function expandFormat(format, lang) {
+ function expandFormat(format, locale) {
var i = 5;
function replaceLongDateFormatTokens(input) {
- return lang.longDateFormat(input) || input;
+ return locale.longDateFormat(input) || input;
}
localFormattingTokens.lastIndex = 0;
@@ -951,6 +1139,8 @@
function getParseRegexForToken(token, config) {
var a, strict = config._strict;
switch (token) {
+ case 'Q':
+ return parseTokenOneDigit;
case 'DDDD':
return parseTokenThreeDigits;
case 'YYYY':
@@ -967,13 +1157,19 @@
case 'ggggg':
return strict ? parseTokenSixDigits : parseTokenOneToSixDigits;
case 'S':
- if (strict) { return parseTokenOneDigit; }
+ if (strict) {
+ return parseTokenOneDigit;
+ }
/* falls through */
case 'SS':
- if (strict) { return parseTokenTwoDigits; }
+ if (strict) {
+ return parseTokenTwoDigits;
+ }
/* falls through */
case 'SSS':
- if (strict) { return parseTokenThreeDigits; }
+ if (strict) {
+ return parseTokenThreeDigits;
+ }
/* falls through */
case 'DDD':
return parseTokenOneToThreeDigits;
@@ -985,7 +1181,9 @@
return parseTokenWord;
case 'a':
case 'A':
- return getLangDefinition(config._l)._meridiemParse;
+ return config._locale._meridiemParse;
+ case 'x':
+ return parseTokenOffsetMs;
case 'X':
return parseTokenTimestampMs;
case 'Z':
@@ -1019,20 +1217,22 @@
case 'e':
case 'E':
return parseTokenOneOrTwoDigits;
+ case 'Do':
+ return strict ? config._locale._ordinalParse : config._locale._ordinalParseLenient;
default :
- a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), "i"));
+ a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), 'i'));
return a;
}
}
- function timezoneMinutesFromString(string) {
- string = string || "";
+ function utcOffsetFromString(string) {
+ string = string || '';
var possibleTzMatches = (string.match(parseTokenTimezone) || []),
tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [],
parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0],
minutes = +(parts[1] * 60) + toInt(parts[2]);
- return parts[0] === '+' ? -minutes : minutes;
+ return parts[0] === '+' ? minutes : -minutes;
}
// function to convert string input to date
@@ -1040,6 +1240,12 @@
var a, datePartArray = config._a;
switch (token) {
+ // QUARTER
+ case 'Q':
+ if (input != null) {
+ datePartArray[MONTH] = (toInt(input) - 1) * 3;
+ }
+ break;
// MONTH
case 'M' : // fall through to MM
case 'MM' :
@@ -1049,7 +1255,7 @@
break;
case 'MMM' : // fall through to MMMM
case 'MMMM' :
- a = getLangDefinition(config._l).monthsParse(input);
+ a = config._locale.monthsParse(input, token, config._strict);
// if we didn't find a month name, mark the date as invalid.
if (a != null) {
datePartArray[MONTH] = a;
@@ -1064,6 +1270,12 @@
datePartArray[DATE] = toInt(input);
}
break;
+ case 'Do' :
+ if (input != null) {
+ datePartArray[DATE] = toInt(parseInt(
+ input.match(/\d{1,2}/)[0], 10));
+ }
+ break;
// DAY OF YEAR
case 'DDD' : // fall through to DDDD
case 'DDDD' :
@@ -1074,7 +1286,7 @@
break;
// YEAR
case 'YY' :
- datePartArray[YEAR] = toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
+ datePartArray[YEAR] = moment.parseTwoDigitYear(input);
break;
case 'YYYY' :
case 'YYYYY' :
@@ -1084,13 +1296,16 @@
// AM / PM
case 'a' : // fall through to A
case 'A' :
- config._isPm = getLangDefinition(config._l).isPM(input);
+ config._meridiem = input;
+ // config._isPm = config._locale.isPM(input);
break;
- // 24 HOUR
- case 'H' : // fall through to hh
- case 'HH' : // fall through to hh
+ // HOUR
case 'h' : // fall through to hh
case 'hh' :
+ config._pf.bigHour = true;
+ /* falls through */
+ case 'H' : // fall through to HH
+ case 'HH' :
datePartArray[HOUR] = toInt(input);
break;
// MINUTE
@@ -1110,6 +1325,10 @@
case 'SSSS' :
datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000);
break;
+ // UNIX OFFSET (MILLISECONDS)
+ case 'x':
+ config._d = new Date(toInt(input));
+ break;
// UNIX TIMESTAMP WITH MS
case 'X':
config._d = new Date(parseFloat(input) * 1000);
@@ -1118,32 +1337,87 @@
case 'Z' : // fall through to ZZ
case 'ZZ' :
config._useUTC = true;
- config._tzm = timezoneMinutesFromString(input);
+ config._tzm = utcOffsetFromString(input);
+ break;
+ // WEEKDAY - human
+ case 'dd':
+ case 'ddd':
+ case 'dddd':
+ a = config._locale.weekdaysParse(input);
+ // if we didn't get a weekday name, mark the date as invalid
+ if (a != null) {
+ config._w = config._w || {};
+ config._w['d'] = a;
+ } else {
+ config._pf.invalidWeekday = input;
+ }
break;
+ // WEEK, WEEK DAY - numeric
case 'w':
case 'ww':
case 'W':
case 'WW':
case 'd':
- case 'dd':
- case 'ddd':
- case 'dddd':
case 'e':
case 'E':
token = token.substr(0, 1);
/* falls through */
- case 'gg':
case 'gggg':
- case 'GG':
case 'GGGG':
case 'GGGGG':
token = token.substr(0, 2);
if (input) {
config._w = config._w || {};
- config._w[token] = input;
+ config._w[token] = toInt(input);
}
break;
+ case 'gg':
+ case 'GG':
+ config._w = config._w || {};
+ config._w[token] = moment.parseTwoDigitYear(input);
+ }
+ }
+
+ function dayOfYearFromWeekInfo(config) {
+ var w, weekYear, week, weekday, dow, doy, temp;
+
+ w = config._w;
+ if (w.GG != null || w.W != null || w.E != null) {
+ dow = 1;
+ doy = 4;
+
+ // TODO: We need to take the current isoWeekYear, but that depends on
+ // how we interpret now (local, utc, fixed offset). So create
+ // a now version of current config (take local/utc/offset flags, and
+ // create now).
+ weekYear = dfl(w.GG, config._a[YEAR], weekOfYear(moment(), 1, 4).year);
+ week = dfl(w.W, 1);
+ weekday = dfl(w.E, 1);
+ } else {
+ dow = config._locale._week.dow;
+ doy = config._locale._week.doy;
+
+ weekYear = dfl(w.gg, config._a[YEAR], weekOfYear(moment(), dow, doy).year);
+ week = dfl(w.w, 1);
+
+ if (w.d != null) {
+ // weekday -- low day numbers are considered next week
+ weekday = w.d;
+ if (weekday < dow) {
+ ++week;
+ }
+ } else if (w.e != null) {
+ // local weekday -- counting starts from begining of week
+ weekday = w.e + dow;
+ } else {
+ // default to begining of week
+ weekday = dow;
+ }
}
+ temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
+
+ config._a[YEAR] = temp.year;
+ config._dayOfYear = temp.dayOfYear;
}
// convert an array to a date.
@@ -1151,8 +1425,7 @@
// note: all values past the year are optional and will default to the lowest possible value.
// [year, month, day , hour, minute, second, millisecond]
function dateFromConfig(config) {
- var i, date, input = [], currentDate,
- yearToUse, fixYear, w, temp, lang, weekday, week;
+ var i, date, input = [], currentDate, yearToUse;
if (config._d) {
return;
@@ -1162,39 +1435,12 @@
//compute day of the year from weeks and weekdays
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
- fixYear = function (val) {
- var int_val = parseInt(val, 10);
- return val ?
- (val.length < 3 ? (int_val > 68 ? 1900 + int_val : 2000 + int_val) : int_val) :
- (config._a[YEAR] == null ? moment().weekYear() : config._a[YEAR]);
- };
-
- w = config._w;
- if (w.GG != null || w.W != null || w.E != null) {
- temp = dayOfYearFromWeeks(fixYear(w.GG), w.W || 1, w.E, 4, 1);
- }
- else {
- lang = getLangDefinition(config._l);
- weekday = w.d != null ? parseWeekday(w.d, lang) :
- (w.e != null ? parseInt(w.e, 10) + lang._week.dow : 0);
-
- week = parseInt(w.w, 10) || 1;
-
- //if we're parsing 'd', then the low day numbers may be next week
- if (w.d != null && weekday < lang._week.dow) {
- week++;
- }
-
- temp = dayOfYearFromWeeks(fixYear(w.gg), week, weekday, lang._week.doy, lang._week.dow);
- }
-
- config._a[YEAR] = temp.year;
- config._dayOfYear = temp.dayOfYear;
+ dayOfYearFromWeekInfo(config);
}
//if the day of the year is set, figure out what it is
if (config._dayOfYear) {
- yearToUse = config._a[YEAR] == null ? currentDate[YEAR] : config._a[YEAR];
+ yearToUse = dfl(config._a[YEAR], currentDate[YEAR]);
if (config._dayOfYear > daysInYear(yearToUse)) {
config._pf._overflowDayOfYear = true;
@@ -1219,11 +1465,25 @@
config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
}
- // add the offsets to the time to be parsed so that we can have a clean array for checking isValid
- input[HOUR] += toInt((config._tzm || 0) / 60);
- input[MINUTE] += toInt((config._tzm || 0) % 60);
+ // Check for 24:00:00.000
+ if (config._a[HOUR] === 24 &&
+ config._a[MINUTE] === 0 &&
+ config._a[SECOND] === 0 &&
+ config._a[MILLISECOND] === 0) {
+ config._nextDay = true;
+ config._a[HOUR] = 0;
+ }
config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input);
+ // Apply timezone offset from input. The actual utcOffset can be changed
+ // with parseZone.
+ if (config._tzm != null) {
+ config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
+ }
+
+ if (config._nextDay) {
+ config._a[HOUR] = 24;
+ }
}
function dateFromObject(config) {
@@ -1237,7 +1497,7 @@
config._a = [
normalizedInput.year,
normalizedInput.month,
- normalizedInput.day,
+ normalizedInput.day || normalizedInput.date,
normalizedInput.hour,
normalizedInput.minute,
normalizedInput.second,
@@ -1262,18 +1522,21 @@
// date from string and format string
function makeDateFromStringAndFormat(config) {
+ if (config._f === moment.ISO_8601) {
+ parseISO(config);
+ return;
+ }
config._a = [];
config._pf.empty = true;
// This array is used to make a Date, either with `new Date` or `Date.UTC`
- var lang = getLangDefinition(config._l),
- string = '' + config._i,
+ var string = '' + config._i,
i, parsedInput, tokens, token, skipped,
stringLength = string.length,
totalParsedInputLength = 0;
- tokens = expandFormat(config._f, lang).match(formattingTokens) || [];
+ tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
for (i = 0; i < tokens.length; i++) {
token = tokens[i];
@@ -1307,15 +1570,13 @@
config._pf.unusedInput.push(string);
}
- // handle am pm
- if (config._isPm && config._a[HOUR] < 12) {
- config._a[HOUR] += 12;
- }
- // if is 12 am, change hours to 0
- if (config._isPm === false && config._a[HOUR] === 12) {
- config._a[HOUR] = 0;
+ // clear _12h flag if hour is <= 12
+ if (config._pf.bigHour === true && config._a[HOUR] <= 12) {
+ config._pf.bigHour = undefined;
}
-
+ // handle meridiem
+ config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR],
+ config._meridiem);
dateFromConfig(config);
checkOverflow(config);
}
@@ -1348,7 +1609,10 @@
for (i = 0; i < config._f.length; i++) {
currentScore = 0;
- tempConfig = extend({}, config);
+ tempConfig = copyConfig({}, config);
+ if (config._useUTC != null) {
+ tempConfig._useUTC = config._useUTC;
+ }
tempConfig._pf = defaultParsingFlags();
tempConfig._f = config._f[i];
makeDateFromStringAndFormat(tempConfig);
@@ -1375,7 +1639,7 @@
}
// date from iso format
- function makeDateFromString(config) {
+ function parseISO(config) {
var i, l,
string = config._i,
match = isoRegex.exec(string);
@@ -1384,8 +1648,8 @@
config._pf.iso = true;
for (i = 0, l = isoDates.length; i < l; i++) {
if (isoDates[i][1].exec(string)) {
- // match[5] should be "T" or undefined
- config._f = isoDates[i][0] + (match[6] || " ");
+ // match[5] should be 'T' or undefined
+ config._f = isoDates[i][0] + (match[6] || ' ');
break;
}
}
@@ -1396,34 +1660,53 @@
}
}
if (string.match(parseTokenTimezone)) {
- config._f += "Z";
+ config._f += 'Z';
}
makeDateFromStringAndFormat(config);
+ } else {
+ config._isValid = false;
}
- else {
- config._d = new Date(string);
+ }
+
+ // date from iso format or fallback
+ function makeDateFromString(config) {
+ parseISO(config);
+ if (config._isValid === false) {
+ delete config._isValid;
+ moment.createFromInputFallback(config);
}
}
- function makeDateFromInput(config) {
- var input = config._i,
- matched = aspNetJsonRegex.exec(input);
+ function map(arr, fn) {
+ var res = [], i;
+ for (i = 0; i < arr.length; ++i) {
+ res.push(fn(arr[i], i));
+ }
+ return res;
+ }
+ function makeDateFromInput(config) {
+ var input = config._i, matched;
if (input === undefined) {
config._d = new Date();
- } else if (matched) {
+ } else if (isDate(input)) {
+ config._d = new Date(+input);
+ } else if ((matched = aspNetJsonRegex.exec(input)) !== null) {
config._d = new Date(+matched[1]);
} else if (typeof input === 'string') {
makeDateFromString(config);
} else if (isArray(input)) {
- config._a = input.slice(0);
+ config._a = map(input.slice(0), function (obj) {
+ return parseInt(obj, 10);
+ });
dateFromConfig(config);
- } else if (isDate(input)) {
- config._d = new Date(+input);
} else if (typeof(input) === 'object') {
dateFromObject(config);
- } else {
+ } else if (typeof(input) === 'number') {
+ // from milliseconds
config._d = new Date(input);
+ } else {
+ moment.createFromInputFallback(config);
}
}
@@ -1447,13 +1730,13 @@
return date;
}
- function parseWeekday(input, language) {
+ function parseWeekday(input, locale) {
if (typeof input === 'string') {
if (!isNaN(input)) {
input = parseInt(input, 10);
}
else {
- input = language.weekdaysParse(input);
+ input = locale.weekdaysParse(input);
if (typeof input !== 'number') {
return null;
}
@@ -1468,29 +1751,33 @@
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
- function substituteTimeAgo(string, number, withoutSuffix, isFuture, lang) {
- return lang.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
+ function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
+ return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
}
- function relativeTime(milliseconds, withoutSuffix, lang) {
- var seconds = round(Math.abs(milliseconds) / 1000),
- minutes = round(seconds / 60),
- hours = round(minutes / 60),
- days = round(hours / 24),
- years = round(days / 365),
- args = seconds < 45 && ['s', seconds] ||
+ function relativeTime(posNegDuration, withoutSuffix, locale) {
+ var duration = moment.duration(posNegDuration).abs(),
+ seconds = round(duration.as('s')),
+ minutes = round(duration.as('m')),
+ hours = round(duration.as('h')),
+ days = round(duration.as('d')),
+ months = round(duration.as('M')),
+ years = round(duration.as('y')),
+
+ args = seconds < relativeTimeThresholds.s && ['s', seconds] ||
minutes === 1 && ['m'] ||
- minutes < 45 && ['mm', minutes] ||
+ minutes < relativeTimeThresholds.m && ['mm', minutes] ||
hours === 1 && ['h'] ||
- hours < 22 && ['hh', hours] ||
+ hours < relativeTimeThresholds.h && ['hh', hours] ||
days === 1 && ['d'] ||
- days <= 25 && ['dd', days] ||
- days <= 45 && ['M'] ||
- days < 345 && ['MM', round(days / 30)] ||
+ days < relativeTimeThresholds.d && ['dd', days] ||
+ months === 1 && ['M'] ||
+ months < relativeTimeThresholds.M && ['MM', months] ||
years === 1 && ['y'] || ['yy', years];
+
args[2] = withoutSuffix;
- args[3] = milliseconds > 0;
- args[4] = lang;
+ args[3] = +posNegDuration > 0;
+ args[4] = locale;
return substituteTimeAgo.apply({}, args);
}
@@ -1521,7 +1808,7 @@
daysToDayOfWeek += 7;
}
- adjustedMoment = moment(mom).add('d', daysToDayOfWeek);
+ adjustedMoment = moment(mom).add(daysToDayOfWeek, 'd');
return {
week: Math.ceil(adjustedMoment.dayOfYear() / 7),
year: adjustedMoment.year()
@@ -1532,6 +1819,7 @@
function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear;
+ d = d === 0 ? 7 : d;
weekday = weekday != null ? weekday : firstDayOfWeek;
daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0);
dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1;
@@ -1548,20 +1836,21 @@
function makeMoment(config) {
var input = config._i,
- format = config._f;
+ format = config._f,
+ res;
+
+ config._locale = config._locale || moment.localeData(config._l);
- if (input === null) {
+ if (input === null || (format === undefined && input === '')) {
return moment.invalid({nullInput: true});
}
if (typeof input === 'string') {
- config._i = input = getLangDefinition().preparse(input);
+ config._i = input = config._locale.preparse(input);
}
if (moment.isMoment(input)) {
- config = cloneMoment(input);
-
- config._d = new Date(+input._d);
+ return new Moment(input, true);
} else if (format) {
if (isArray(format)) {
makeDateFromStringAndArray(config);
@@ -1572,15 +1861,22 @@
makeDateFromInput(config);
}
- return new Moment(config);
+ res = new Moment(config);
+ if (res._nextDay) {
+ // Adding is smart enough around DST
+ res.add(1, 'd');
+ res._nextDay = undefined;
+ }
+
+ return res;
}
- moment = function (input, format, lang, strict) {
+ moment = function (input, format, locale, strict) {
var c;
- if (typeof(lang) === "boolean") {
- strict = lang;
- lang = undefined;
+ if (typeof(locale) === 'boolean') {
+ strict = locale;
+ locale = undefined;
}
// object construction must be done this way.
// https://github.com/moment/moment/issues/1423
@@ -1588,7 +1884,7 @@
c._isAMomentObject = true;
c._i = input;
c._f = format;
- c._l = lang;
+ c._l = locale;
c._strict = strict;
c._isUTC = false;
c._pf = defaultParsingFlags();
@@ -1596,13 +1892,59 @@
return makeMoment(c);
};
+ moment.suppressDeprecationWarnings = false;
+
+ moment.createFromInputFallback = deprecate(
+ 'moment construction falls back to js Date. This is ' +
+ 'discouraged and will be removed in upcoming major ' +
+ 'release. Please refer to ' +
+ 'https://github.com/moment/moment/issues/1407 for more info.',
+ function (config) {
+ config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
+ }
+ );
+
+ // Pick a moment m from moments so that m[fn](other) is true for all
+ // other. This relies on the function fn to be transitive.
+ //
+ // moments should either be an array of moment objects or an array, whose
+ // first element is an array of moment objects.
+ function pickBy(fn, moments) {
+ var res, i;
+ if (moments.length === 1 && isArray(moments[0])) {
+ moments = moments[0];
+ }
+ if (!moments.length) {
+ return moment();
+ }
+ res = moments[0];
+ for (i = 1; i < moments.length; ++i) {
+ if (moments[i][fn](res)) {
+ res = moments[i];
+ }
+ }
+ return res;
+ }
+
+ moment.min = function () {
+ var args = [].slice.call(arguments, 0);
+
+ return pickBy('isBefore', args);
+ };
+
+ moment.max = function () {
+ var args = [].slice.call(arguments, 0);
+
+ return pickBy('isAfter', args);
+ };
+
// creating with utc
- moment.utc = function (input, format, lang, strict) {
+ moment.utc = function (input, format, locale, strict) {
var c;
- if (typeof(lang) === "boolean") {
- strict = lang;
- lang = undefined;
+ if (typeof(locale) === 'boolean') {
+ strict = locale;
+ locale = undefined;
}
// object construction must be done this way.
// https://github.com/moment/moment/issues/1423
@@ -1610,7 +1952,7 @@
c._isAMomentObject = true;
c._useUTC = true;
c._isUTC = true;
- c._l = lang;
+ c._l = locale;
c._i = input;
c._f = format;
c._strict = strict;
@@ -1631,7 +1973,8 @@
match = null,
sign,
ret,
- parseIso;
+ parseIso,
+ diffRes;
if (moment.isDuration(input)) {
duration = {
@@ -1647,7 +1990,7 @@
duration.milliseconds = input;
}
} else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) {
- sign = (match[1] === "-") ? -1 : 1;
+ sign = (match[1] === '-') ? -1 : 1;
duration = {
y: 0,
d: toInt(match[DATE]) * sign,
@@ -1657,7 +2000,7 @@
ms: toInt(match[MILLISECOND]) * sign
};
} else if (!!(match = isoDurationRegex.exec(input))) {
- sign = (match[1] === "-") ? -1 : 1;
+ sign = (match[1] === '-') ? -1 : 1;
parseIso = function (inp) {
// We'd normally use ~~inp for this, but unfortunately it also
// converts floats to ints.
@@ -1675,12 +2018,21 @@
s: parseIso(match[7]),
w: parseIso(match[8])
};
+ } else if (duration == null) {// checks for null or undefined
+ duration = {};
+ } else if (typeof duration === 'object' &&
+ ('from' in duration || 'to' in duration)) {
+ diffRes = momentsDifference(moment(duration.from), moment(duration.to));
+
+ duration = {};
+ duration.ms = diffRes.milliseconds;
+ duration.M = diffRes.months;
}
ret = new Duration(duration);
- if (moment.isDuration(input) && input.hasOwnProperty('_lang')) {
- ret._lang = input._lang;
+ if (moment.isDuration(input) && hasOwnProp(input, '_locale')) {
+ ret._locale = input._locale;
}
return ret;
@@ -1692,42 +2044,111 @@
// default format
moment.defaultFormat = isoFormat;
+ // constant that refers to the ISO standard
+ moment.ISO_8601 = function () {};
+
+ // Plugins that add properties should also add the key here (null value),
+ // so we can properly clone ourselves.
+ moment.momentProperties = momentProperties;
+
// This function will be called whenever a moment is mutated.
// It is intended to keep the offset in sync with the timezone.
moment.updateOffset = function () {};
- // This function will load languages and then set the global language. If
+ // This function allows you to set a threshold for relative time strings
+ moment.relativeTimeThreshold = function (threshold, limit) {
+ if (relativeTimeThresholds[threshold] === undefined) {
+ return false;
+ }
+ if (limit === undefined) {
+ return relativeTimeThresholds[threshold];
+ }
+ relativeTimeThresholds[threshold] = limit;
+ return true;
+ };
+
+ moment.lang = deprecate(
+ 'moment.lang is deprecated. Use moment.locale instead.',
+ function (key, value) {
+ return moment.locale(key, value);
+ }
+ );
+
+ // This function will load locale and then set the global locale. If
// no arguments are passed in, it will simply return the current global
- // language key.
- moment.lang = function (key, values) {
- var r;
- if (!key) {
- return moment.fn._lang._abbr;
- }
- if (values) {
- loadLang(normalizeLanguage(key), values);
- } else if (values === null) {
- unloadLang(key);
- key = 'en';
- } else if (!languages[key]) {
- getLangDefinition(key);
- }
- r = moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key);
- return r._abbr;
+ // locale key.
+ moment.locale = function (key, values) {
+ var data;
+ if (key) {
+ if (typeof(values) !== 'undefined') {
+ data = moment.defineLocale(key, values);
+ }
+ else {
+ data = moment.localeData(key);
+ }
+
+ if (data) {
+ moment.duration._locale = moment._locale = data;
+ }
+ }
+
+ return moment._locale._abbr;
+ };
+
+ moment.defineLocale = function (name, values) {
+ if (values !== null) {
+ values.abbr = name;
+ if (!locales[name]) {
+ locales[name] = new Locale();
+ }
+ locales[name].set(values);
+
+ // backwards compat for now: also set the locale
+ moment.locale(name);
+
+ return locales[name];
+ } else {
+ // useful for testing
+ delete locales[name];
+ return null;
+ }
};
- // returns language data
- moment.langData = function (key) {
- if (key && key._lang && key._lang._abbr) {
- key = key._lang._abbr;
+ moment.langData = deprecate(
+ 'moment.langData is deprecated. Use moment.localeData instead.',
+ function (key) {
+ return moment.localeData(key);
}
- return getLangDefinition(key);
+ );
+
+ // returns locale data
+ moment.localeData = function (key) {
+ var locale;
+
+ if (key && key._locale && key._locale._abbr) {
+ key = key._locale._abbr;
+ }
+
+ if (!key) {
+ return moment._locale;
+ }
+
+ if (!isArray(key)) {
+ //short-circuit everything else
+ locale = loadLocale(key);
+ if (locale) {
+ return locale;
+ }
+ key = [key];
+ }
+
+ return chooseLocale(key);
};
// compare moment object
moment.isMoment = function (obj) {
return obj instanceof Moment ||
- (obj != null && obj.hasOwnProperty('_isAMomentObject'));
+ (obj != null && hasOwnProp(obj, '_isAMomentObject'));
};
// for typechecking Duration objects
@@ -1755,10 +2176,16 @@
return m;
};
- moment.parseZone = function (input) {
- return moment(input).parseZone();
+ moment.parseZone = function () {
+ return moment.apply(null, arguments).parseZone();
};
+ moment.parseTwoDigitYear = function (input) {
+ return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
+ };
+
+ moment.isDate = isDate;
+
/************************************
Moment Prototype
************************************/
@@ -1771,7 +2198,7 @@
},
valueOf : function () {
- return +this._d + ((this._offset || 0) * 60000);
+ return +this._d - ((this._offset || 0) * 60000);
},
unix : function () {
@@ -1779,7 +2206,7 @@
},
toString : function () {
- return this.clone().lang('en').format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ");
+ return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
},
toDate : function () {
@@ -1789,7 +2216,12 @@
toISOString : function () {
var m = moment(this).utc();
if (0 < m.year() && m.year() <= 9999) {
- return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ if ('function' === typeof Date.prototype.toISOString) {
+ // native implementation is ~50x faster, use it when we can
+ return this.toDate().toISOString();
+ } else {
+ return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ }
} else {
return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
}
@@ -1813,7 +2245,6 @@
},
isDSTShifted : function () {
-
if (this._a) {
return this.isValid() && compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()) > 0;
}
@@ -1829,69 +2260,47 @@
return this._pf.overflow;
},
- utc : function () {
- return this.zone(0);
+ utc : function (keepLocalTime) {
+ return this.utcOffset(0, keepLocalTime);
},
- local : function () {
- this.zone(0);
- this._isUTC = false;
+ local : function (keepLocalTime) {
+ if (this._isUTC) {
+ this.utcOffset(0, keepLocalTime);
+ this._isUTC = false;
+
+ if (keepLocalTime) {
+ this.subtract(this._dateUtcOffset(), 'm');
+ }
+ }
return this;
},
format : function (inputString) {
var output = formatMoment(this, inputString || moment.defaultFormat);
- return this.lang().postformat(output);
+ return this.localeData().postformat(output);
},
- add : function (input, val) {
- var dur;
- // switch args to support add('s', 1) and add(1, 's')
- if (typeof input === 'string') {
- dur = moment.duration(+val, input);
- } else {
- dur = moment.duration(input, val);
- }
- addOrSubtractDurationFromMoment(this, dur, 1);
- return this;
- },
+ add : createAdder(1, 'add'),
- subtract : function (input, val) {
- var dur;
- // switch args to support subtract('s', 1) and subtract(1, 's')
- if (typeof input === 'string') {
- dur = moment.duration(+val, input);
- } else {
- dur = moment.duration(input, val);
- }
- addOrSubtractDurationFromMoment(this, dur, -1);
- return this;
- },
+ subtract : createAdder(-1, 'subtract'),
diff : function (input, units, asFloat) {
var that = makeAs(input, this),
- zoneDiff = (this.zone() - that.zone()) * 6e4,
- diff, output;
+ zoneDiff = (that.utcOffset() - this.utcOffset()) * 6e4,
+ anchor, diff, output, daysAdjust;
units = normalizeUnits(units);
- if (units === 'year' || units === 'month') {
- // average number of days in the months in the given dates
- diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2
- // difference in months
- output = ((this.year() - that.year()) * 12) + (this.month() - that.month());
- // adjust by taking difference in days, average number of days
- // and dst in the given months.
- output += ((this - moment(this).startOf('month')) -
- (that - moment(that).startOf('month'))) / diff;
- // same as above but with zones, to negate all dst
- output -= ((this.zone() - moment(this).startOf('month').zone()) -
- (that.zone() - moment(that).startOf('month').zone())) * 6e4 / diff;
- if (units === 'year') {
+ if (units === 'year' || units === 'month' || units === 'quarter') {
+ output = monthDiff(this, that);
+ if (units === 'quarter') {
+ output = output / 3;
+ } else if (units === 'year') {
output = output / 12;
}
} else {
- diff = (this - that);
+ diff = this - that;
output = units === 'second' ? diff / 1e3 : // 1000
units === 'minute' ? diff / 6e4 : // 1000 * 60
units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60
@@ -1903,17 +2312,19 @@
},
from : function (time, withoutSuffix) {
- return moment.duration(this.diff(time)).lang(this.lang()._abbr).humanize(!withoutSuffix);
+ return moment.duration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
},
fromNow : function (withoutSuffix) {
return this.from(moment(), withoutSuffix);
},
- calendar : function () {
+ calendar : function (time) {
// We want to compare the start of today, vs this.
- // Getting start-of-today depends on whether we're zone'd or not.
- var sod = makeAs(moment(), this).startOf('day'),
+ // Getting start-of-today depends on whether we're locat/utc/offset
+ // or not.
+ var now = time || moment(),
+ sod = makeAs(now, this).startOf('day'),
diff = this.diff(sod, 'days', true),
format = diff < -6 ? 'sameElse' :
diff < -1 ? 'lastWeek' :
@@ -1921,7 +2332,7 @@
diff < 1 ? 'sameDay' :
diff < 2 ? 'nextDay' :
diff < 7 ? 'nextWeek' : 'sameElse';
- return this.format(this.lang().calendar(format, this));
+ return this.format(this.localeData().calendar(format, this, moment(now)));
},
isLeapYear : function () {
@@ -1929,45 +2340,23 @@
},
isDST : function () {
- return (this.zone() < this.clone().month(0).zone() ||
- this.zone() < this.clone().month(5).zone());
+ return (this.utcOffset() > this.clone().month(0).utcOffset() ||
+ this.utcOffset() > this.clone().month(5).utcOffset());
},
day : function (input) {
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
if (input != null) {
- input = parseWeekday(input, this.lang());
- return this.add({ d : input - day });
+ input = parseWeekday(input, this.localeData());
+ return this.add(input - day, 'd');
} else {
return day;
}
},
- month : function (input) {
- var utc = this._isUTC ? 'UTC' : '',
- dayOfMonth;
+ month : makeAccessor('Month', true),
- if (input != null) {
- if (typeof input === 'string') {
- input = this.lang().monthsParse(input);
- if (typeof input !== 'number') {
- return this;
- }
- }
-
- dayOfMonth = this.date();
- this.date(1);
- this._d['set' + utc + 'Month'](input);
- this.date(Math.min(dayOfMonth, this.daysInMonth()));
-
- moment.updateOffset(this);
- return this;
- } else {
- return this._d['get' + utc + 'Month']();
- }
- },
-
- startOf: function (units) {
+ startOf : function (units) {
units = normalizeUnits(units);
// the following switch intentionally omits break keywords
// to utilize falling through the cases.
@@ -1975,6 +2364,7 @@
case 'year':
this.month(0);
/* falls through */
+ case 'quarter':
case 'month':
this.date(1);
/* falls through */
@@ -2001,72 +2391,166 @@
this.isoWeekday(1);
}
+ // quarters are also special
+ if (units === 'quarter') {
+ this.month(Math.floor(this.month() / 3) * 3);
+ }
+
return this;
},
endOf: function (units) {
units = normalizeUnits(units);
- return this.startOf(units).add((units === 'isoWeek' ? 'week' : units), 1).subtract('ms', 1);
+ if (units === undefined || units === 'millisecond') {
+ return this;
+ }
+ return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
},
isAfter: function (input, units) {
- units = typeof units !== 'undefined' ? units : 'millisecond';
- return +this.clone().startOf(units) > +moment(input).startOf(units);
+ var inputMs;
+ units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
+ if (units === 'millisecond') {
+ input = moment.isMoment(input) ? input : moment(input);
+ return +this > +input;
+ } else {
+ inputMs = moment.isMoment(input) ? +input : +moment(input);
+ return inputMs < +this.clone().startOf(units);
+ }
},
isBefore: function (input, units) {
- units = typeof units !== 'undefined' ? units : 'millisecond';
- return +this.clone().startOf(units) < +moment(input).startOf(units);
+ var inputMs;
+ units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
+ if (units === 'millisecond') {
+ input = moment.isMoment(input) ? input : moment(input);
+ return +this < +input;
+ } else {
+ inputMs = moment.isMoment(input) ? +input : +moment(input);
+ return +this.clone().endOf(units) < inputMs;
+ }
},
- isSame: function (input, units) {
- units = units || 'ms';
- return +this.clone().startOf(units) === +makeAs(input, this).startOf(units);
+ isBetween: function (from, to, units) {
+ return this.isAfter(from, units) && this.isBefore(to, units);
},
- min: function (other) {
- other = moment.apply(null, arguments);
- return other < this ? this : other;
+ isSame: function (input, units) {
+ var inputMs;
+ units = normalizeUnits(units || 'millisecond');
+ if (units === 'millisecond') {
+ input = moment.isMoment(input) ? input : moment(input);
+ return +this === +input;
+ } else {
+ inputMs = +moment(input);
+ return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
+ }
},
- max: function (other) {
- other = moment.apply(null, arguments);
- return other > this ? this : other;
- },
+ min: deprecate(
+ 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
+ function (other) {
+ other = moment.apply(null, arguments);
+ return other < this ? this : other;
+ }
+ ),
- zone : function (input) {
- var offset = this._offset || 0;
+ max: deprecate(
+ 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
+ function (other) {
+ other = moment.apply(null, arguments);
+ return other > this ? this : other;
+ }
+ ),
+
+ zone : deprecate(
+ 'moment().zone is deprecated, use moment().utcOffset instead. ' +
+ 'https://github.com/moment/moment/issues/1779',
+ function (input, keepLocalTime) {
+ if (input != null) {
+ if (typeof input !== 'string') {
+ input = -input;
+ }
+
+ this.utcOffset(input, keepLocalTime);
+
+ return this;
+ } else {
+ return -this.utcOffset();
+ }
+ }
+ ),
+
+ // keepLocalTime = true means only change the timezone, without
+ // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
+ // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
+ // +0200, so we adjust the time as needed, to be valid.
+ //
+ // Keeping the time actually adds/subtracts (one hour)
+ // from the actual represented time. That is why we call updateOffset
+ // a second time. In case it wants us to change the offset again
+ // _changeInProgress == true case, then we have to adjust, because
+ // there is no such time in the given timezone.
+ utcOffset : function (input, keepLocalTime) {
+ var offset = this._offset || 0,
+ localAdjust;
if (input != null) {
- if (typeof input === "string") {
- input = timezoneMinutesFromString(input);
+ if (typeof input === 'string') {
+ input = utcOffsetFromString(input);
}
if (Math.abs(input) < 16) {
input = input * 60;
}
+ if (!this._isUTC && keepLocalTime) {
+ localAdjust = this._dateUtcOffset();
+ }
this._offset = input;
this._isUTC = true;
+ if (localAdjust != null) {
+ this.add(localAdjust, 'm');
+ }
if (offset !== input) {
- addOrSubtractDurationFromMoment(this, moment.duration(offset - input, 'm'), 1, true);
+ if (!keepLocalTime || this._changeInProgress) {
+ addOrSubtractDurationFromMoment(this,
+ moment.duration(input - offset, 'm'), 1, false);
+ } else if (!this._changeInProgress) {
+ this._changeInProgress = true;
+ moment.updateOffset(this, true);
+ this._changeInProgress = null;
+ }
}
+
+ return this;
} else {
- return this._isUTC ? offset : this._d.getTimezoneOffset();
+ return this._isUTC ? offset : this._dateUtcOffset();
}
- return this;
+ },
+
+ isLocal : function () {
+ return !this._isUTC;
+ },
+
+ isUtcOffset : function () {
+ return this._isUTC;
+ },
+
+ isUtc : function () {
+ return this._isUTC && this._offset === 0;
},
zoneAbbr : function () {
- return this._isUTC ? "UTC" : "";
+ return this._isUTC ? 'UTC' : '';
},
zoneName : function () {
- return this._isUTC ? "Coordinated Universal Time" : "";
+ return this._isUTC ? 'Coordinated Universal Time' : '';
},
parseZone : function () {
if (this._tzm) {
- this.zone(this._tzm);
+ this.utcOffset(this._tzm);
} else if (typeof this._i === 'string') {
- this.zone(this._i);
+ this.utcOffset(utcOffsetFromString(this._i));
}
return this;
},
@@ -2076,10 +2560,10 @@
input = 0;
}
else {
- input = moment(input).zone();
+ input = moment(input).utcOffset();
}
- return (this.zone() - input) % 60 === 0;
+ return (this.utcOffset() - input) % 60 === 0;
},
daysInMonth : function () {
@@ -2088,36 +2572,36 @@
dayOfYear : function (input) {
var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1;
- return input == null ? dayOfYear : this.add("d", (input - dayOfYear));
+ return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
},
- quarter : function () {
- return Math.ceil((this.month() + 1.0) / 3.0);
+ quarter : function (input) {
+ return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
},
weekYear : function (input) {
- var year = weekOfYear(this, this.lang()._week.dow, this.lang()._week.doy).year;
- return input == null ? year : this.add("y", (input - year));
+ var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
+ return input == null ? year : this.add((input - year), 'y');
},
isoWeekYear : function (input) {
var year = weekOfYear(this, 1, 4).year;
- return input == null ? year : this.add("y", (input - year));
+ return input == null ? year : this.add((input - year), 'y');
},
week : function (input) {
- var week = this.lang().week(this);
- return input == null ? week : this.add("d", (input - week) * 7);
+ var week = this.localeData().week(this);
+ return input == null ? week : this.add((input - week) * 7, 'd');
},
isoWeek : function (input) {
var week = weekOfYear(this, 1, 4).week;
- return input == null ? week : this.add("d", (input - week) * 7);
+ return input == null ? week : this.add((input - week) * 7, 'd');
},
weekday : function (input) {
- var weekday = (this.day() + 7 - this.lang()._week.dow) % 7;
- return input == null ? weekday : this.add("d", input - weekday);
+ var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
+ return input == null ? weekday : this.add(input - weekday, 'd');
},
isoWeekday : function (input) {
@@ -2127,68 +2611,161 @@
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
},
+ isoWeeksInYear : function () {
+ return weeksInYear(this.year(), 1, 4);
+ },
+
+ weeksInYear : function () {
+ var weekInfo = this.localeData()._week;
+ return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
+ },
+
get : function (units) {
units = normalizeUnits(units);
return this[units]();
},
set : function (units, value) {
- units = normalizeUnits(units);
- if (typeof this[units] === 'function') {
- this[units](value);
+ var unit;
+ if (typeof units === 'object') {
+ for (unit in units) {
+ this.set(unit, units[unit]);
+ }
+ }
+ else {
+ units = normalizeUnits(units);
+ if (typeof this[units] === 'function') {
+ this[units](value);
+ }
}
return this;
},
- // If passed a language key, it will set the language for this
- // instance. Otherwise, it will return the language configuration
+ // If passed a locale key, it will set the locale for this
+ // instance. Otherwise, it will return the locale configuration
// variables for this instance.
- lang : function (key) {
+ locale : function (key) {
+ var newLocaleData;
+
if (key === undefined) {
- return this._lang;
+ return this._locale._abbr;
} else {
- this._lang = getLangDefinition(key);
+ newLocaleData = moment.localeData(key);
+ if (newLocaleData != null) {
+ this._locale = newLocaleData;
+ }
return this;
}
+ },
+
+ lang : deprecate(
+ 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
+ function (key) {
+ if (key === undefined) {
+ return this.localeData();
+ } else {
+ return this.locale(key);
+ }
+ }
+ ),
+
+ localeData : function () {
+ return this._locale;
+ },
+
+ _dateUtcOffset : function () {
+ // On Firefox.24 Date#getTimezoneOffset returns a floating point.
+ // https://github.com/moment/moment/pull/1871
+ return -Math.round(this._d.getTimezoneOffset() / 15) * 15;
}
+
});
- // helper for adding shortcuts
- function makeGetterAndSetter(name, key) {
- moment.fn[name] = moment.fn[name + 's'] = function (input) {
- var utc = this._isUTC ? 'UTC' : '';
- if (input != null) {
- this._d['set' + utc + key](input);
- moment.updateOffset(this);
+ function rawMonthSetter(mom, value) {
+ var dayOfMonth;
+
+ // TODO: Move this out of here!
+ if (typeof value === 'string') {
+ value = mom.localeData().monthsParse(value);
+ // TODO: Another silent failure?
+ if (typeof value !== 'number') {
+ return mom;
+ }
+ }
+
+ dayOfMonth = Math.min(mom.date(),
+ daysInMonth(mom.year(), value));
+ mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
+ return mom;
+ }
+
+ function rawGetter(mom, unit) {
+ return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
+ }
+
+ function rawSetter(mom, unit, value) {
+ if (unit === 'Month') {
+ return rawMonthSetter(mom, value);
+ } else {
+ return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
+ }
+ }
+
+ function makeAccessor(unit, keepTime) {
+ return function (value) {
+ if (value != null) {
+ rawSetter(this, unit, value);
+ moment.updateOffset(this, keepTime);
return this;
} else {
- return this._d['get' + utc + key]();
+ return rawGetter(this, unit);
}
};
}
- // loop through and add shortcuts (Month, Date, Hours, Minutes, Seconds, Milliseconds)
- for (i = 0; i < proxyGettersAndSetters.length; i ++) {
- makeGetterAndSetter(proxyGettersAndSetters[i].toLowerCase().replace(/s$/, ''), proxyGettersAndSetters[i]);
- }
-
- // add shortcut for year (uses different syntax than the getter/setter 'year' == 'FullYear')
- makeGetterAndSetter('year', 'FullYear');
+ moment.fn.millisecond = moment.fn.milliseconds = makeAccessor('Milliseconds', false);
+ moment.fn.second = moment.fn.seconds = makeAccessor('Seconds', false);
+ moment.fn.minute = moment.fn.minutes = makeAccessor('Minutes', false);
+ // Setting the hour should keep the time, because the user explicitly
+ // specified which hour he wants. So trying to maintain the same hour (in
+ // a new timezone) makes sense. Adding/subtracting hours does not follow
+ // this rule.
+ moment.fn.hour = moment.fn.hours = makeAccessor('Hours', true);
+ // moment.fn.month is defined separately
+ moment.fn.date = makeAccessor('Date', true);
+ moment.fn.dates = deprecate('dates accessor is deprecated. Use date instead.', makeAccessor('Date', true));
+ moment.fn.year = makeAccessor('FullYear', true);
+ moment.fn.years = deprecate('years accessor is deprecated. Use year instead.', makeAccessor('FullYear', true));
// add plural methods
moment.fn.days = moment.fn.day;
moment.fn.months = moment.fn.month;
moment.fn.weeks = moment.fn.week;
moment.fn.isoWeeks = moment.fn.isoWeek;
+ moment.fn.quarters = moment.fn.quarter;
// add aliased format methods
moment.fn.toJSON = moment.fn.toISOString;
+ // alias isUtc for dev-friendliness
+ moment.fn.isUTC = moment.fn.isUtc;
+
/************************************
Duration Prototype
************************************/
+ function daysToYears (days) {
+ // 400 years have 146097 days (taking into account leap year rules)
+ return days * 400 / 146097;
+ }
+
+ function yearsToDays (years) {
+ // years * 365 + absRound(years / 4) -
+ // absRound(years / 100) + absRound(years / 400);
+ return years * 146097 / 400;
+ }
+
extend(moment.duration.fn = Duration.prototype, {
_bubble : function () {
@@ -2196,7 +2773,7 @@
days = this._days,
months = this._months,
data = this._data,
- seconds, minutes, hours, years;
+ seconds, minutes, hours, years = 0;
// The following code bubbles up values, see the tests for
// examples of what that means.
@@ -2212,15 +2789,40 @@
data.hours = hours % 24;
days += absRound(hours / 24);
- data.days = days % 30;
+ // Accurately convert days to years, assume start from year 0.
+ years = absRound(daysToYears(days));
+ days -= absRound(yearsToDays(years));
+
+ // 30 days to a month
+ // TODO (iskren): Use anchor date (like 1st Jan) to compute this.
months += absRound(days / 30);
- data.months = months % 12;
+ days %= 30;
+
+ // 12 months -> 1 year
+ years += absRound(months / 12);
+ months %= 12;
- years = absRound(months / 12);
+ data.days = days;
+ data.months = months;
data.years = years;
},
+ abs : function () {
+ this._milliseconds = Math.abs(this._milliseconds);
+ this._days = Math.abs(this._days);
+ this._months = Math.abs(this._months);
+
+ this._data.milliseconds = Math.abs(this._data.milliseconds);
+ this._data.seconds = Math.abs(this._data.seconds);
+ this._data.minutes = Math.abs(this._data.minutes);
+ this._data.hours = Math.abs(this._data.hours);
+ this._data.months = Math.abs(this._data.months);
+ this._data.years = Math.abs(this._data.years);
+
+ return this;
+ },
+
weeks : function () {
return absRound(this.days() / 7);
},
@@ -2233,14 +2835,13 @@
},
humanize : function (withSuffix) {
- var difference = +this,
- output = relativeTime(difference, !withSuffix, this.lang());
+ var output = relativeTime(this, !withSuffix, this.localeData());
if (withSuffix) {
- output = this.lang().pastFuture(difference, output);
+ output = this.localeData().pastFuture(+this, output);
}
- return this.lang().postformat(output);
+ return this.localeData().postformat(output);
},
add : function (input, val) {
@@ -2274,13 +2875,41 @@
},
as : function (units) {
+ var days, months;
units = normalizeUnits(units);
- return this['as' + units.charAt(0).toUpperCase() + units.slice(1) + 's']();
+
+ if (units === 'month' || units === 'year') {
+ days = this._days + this._milliseconds / 864e5;
+ months = this._months + daysToYears(days) * 12;
+ return units === 'month' ? months : months / 12;
+ } else {
+ // handle milliseconds separately because of floating point math errors (issue #1867)
+ days = this._days + Math.round(yearsToDays(this._months / 12));
+ switch (units) {
+ case 'week': return days / 7 + this._milliseconds / 6048e5;
+ case 'day': return days + this._milliseconds / 864e5;
+ case 'hour': return days * 24 + this._milliseconds / 36e5;
+ case 'minute': return days * 24 * 60 + this._milliseconds / 6e4;
+ case 'second': return days * 24 * 60 * 60 + this._milliseconds / 1000;
+ // Math.floor prevents floating point math errors here
+ case 'millisecond': return Math.floor(days * 24 * 60 * 60 * 1000) + this._milliseconds;
+ default: throw new Error('Unknown unit ' + units);
+ }
+ }
},
lang : moment.fn.lang,
+ locale : moment.fn.locale,
+
+ toIsoString : deprecate(
+ 'toIsoString() is deprecated. Please use toISOString() instead ' +
+ '(notice the capitals)',
+ function () {
+ return this.toISOString();
+ }
+ ),
- toIsoString : function () {
+ toISOString : function () {
// inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
var years = Math.abs(this.years()),
months = Math.abs(this.months()),
@@ -2304,41 +2933,64 @@
(hours ? hours + 'H' : '') +
(minutes ? minutes + 'M' : '') +
(seconds ? seconds + 'S' : '');
+ },
+
+ localeData : function () {
+ return this._locale;
+ },
+
+ toJSON : function () {
+ return this.toISOString();
}
});
+ moment.duration.fn.toString = moment.duration.fn.toISOString;
+
function makeDurationGetter(name) {
moment.duration.fn[name] = function () {
return this._data[name];
};
}
- function makeDurationAsGetter(name, factor) {
- moment.duration.fn['as' + name] = function () {
- return +this / factor;
- };
- }
-
for (i in unitMillisecondFactors) {
- if (unitMillisecondFactors.hasOwnProperty(i)) {
- makeDurationAsGetter(i, unitMillisecondFactors[i]);
+ if (hasOwnProp(unitMillisecondFactors, i)) {
makeDurationGetter(i.toLowerCase());
}
}
- makeDurationAsGetter('Weeks', 6048e5);
+ moment.duration.fn.asMilliseconds = function () {
+ return this.as('ms');
+ };
+ moment.duration.fn.asSeconds = function () {
+ return this.as('s');
+ };
+ moment.duration.fn.asMinutes = function () {
+ return this.as('m');
+ };
+ moment.duration.fn.asHours = function () {
+ return this.as('h');
+ };
+ moment.duration.fn.asDays = function () {
+ return this.as('d');
+ };
+ moment.duration.fn.asWeeks = function () {
+ return this.as('weeks');
+ };
moment.duration.fn.asMonths = function () {
- return (+this - this.years() * 31536e6) / 2592e6 + this.years() * 12;
+ return this.as('M');
+ };
+ moment.duration.fn.asYears = function () {
+ return this.as('y');
};
-
/************************************
- Default Lang
+ Default Locale
************************************/
- // Set default language, other languages will inherit from English.
- moment.lang('en', {
+ // Set default locale, other locale will inherit from English.
+ moment.locale('en', {
+ ordinalParse: /\d{1,2}(th|st|nd|rd)/,
ordinal : function (number) {
var b = number % 10,
output = (toInt(number % 100 / 10) === 1) ? 'th' :
@@ -2349,51 +3001,42 @@
}
});
- /* EMBED_LANGUAGES */
+ /* EMBED_LOCALES */
/************************************
Exposing Moment
************************************/
- function makeGlobal(deprecate) {
- var warned = false, local_moment = moment;
+ function makeGlobal(shouldDeprecate) {
/*global ender:false */
if (typeof ender !== 'undefined') {
return;
}
- // here, `this` means `window` in the browser, or `global` on the server
- // add `moment` as a global object via a string identifier,
- // for Closure Compiler "advanced" mode
- if (deprecate) {
- global.moment = function () {
- if (!warned && console && console.warn) {
- warned = true;
- console.warn(
- "Accessing Moment through the global scope is " +
- "deprecated, and will be removed in an upcoming " +
- "release.");
- }
- return local_moment.apply(null, arguments);
- };
- extend(global.moment, local_moment);
+ oldGlobalMoment = globalScope.moment;
+ if (shouldDeprecate) {
+ globalScope.moment = deprecate(
+ 'Accessing Moment through the global scope is ' +
+ 'deprecated, and will be removed in an upcoming ' +
+ 'release.',
+ moment);
} else {
- global['moment'] = moment;
+ globalScope.moment = moment;
}
}
// CommonJS module is defined
if (hasModule) {
module.exports = moment;
- makeGlobal(true);
- } else if (typeof define === "function" && define.amd) {
- define("moment", function (require, exports, module) {
- if (module.config && module.config() && module.config().noGlobal !== true) {
- // If user provided noGlobal, he is aware of global
- makeGlobal(module.config().noGlobal === undefined);
+ } else if (typeof define === 'function' && define.amd) {
+ define(function (require, exports, module) {
+ if (module.config && module.config() && module.config().noGlobal === true) {
+ // release the global variable
+ globalScope.moment = oldGlobalMoment;
}
return moment;
});
+ makeGlobal(true);
} else {
makeGlobal();
}
diff --git a/app/assets/stylesheets/blazer/daterangepicker-bs3.css b/app/assets/stylesheets/blazer/daterangepicker-bs3.css
index cf6e5626..3ff82716 100644
--- a/app/assets/stylesheets/blazer/daterangepicker-bs3.css
+++ b/app/assets/stylesheets/blazer/daterangepicker-bs3.css
@@ -1,9 +1,8 @@
/*!
* Stylesheet for the Date Range Picker, for use with Bootstrap 3.x
*
- * Copyright 2013 Dan Grossman ( http://www.dangrossman.info )
- * Licensed under the Apache License v2.0
- * http://www.apache.org/licenses/LICENSE-2.0
+ * Copyright 2013-2015 Dan Grossman ( http://www.dangrossman.info )
+ * Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
*
* Built for http://www.improvely.com
*/
@@ -18,11 +17,16 @@
margin: 4px;
}
-.daterangepicker.opensright .ranges, .daterangepicker.opensright .calendar {
+.daterangepicker.opensright .ranges, .daterangepicker.opensright .calendar,
+.daterangepicker.openscenter .ranges, .daterangepicker.openscenter .calendar {
float: right;
margin: 4px;
}
+.daterangepicker.single .ranges, .daterangepicker.single .calendar {
+ float: none;
+}
+
.daterangepicker .ranges {
width: 160px;
text-align: left;
@@ -75,7 +79,6 @@
}
.daterangepicker .ranges .input-mini {
- background-color: #eee;
border: 1px solid #ccc;
border-radius: 4px;
color: #555;
@@ -162,6 +165,37 @@
content: '';
}
+.daterangepicker.openscenter:before {
+ position: absolute;
+ top: -7px;
+ left: 0;
+ right: 0;
+ width: 0;
+ margin-left: auto;
+ margin-right: auto;
+ display: inline-block;
+ border-right: 7px solid transparent;
+ border-bottom: 7px solid #ccc;
+ border-left: 7px solid transparent;
+ border-bottom-color: rgba(0, 0, 0, 0.2);
+ content: '';
+}
+
+.daterangepicker.openscenter:after {
+ position: absolute;
+ top: -6px;
+ left: 0;
+ right: 0;
+ width: 0;
+ margin-left: auto;
+ margin-right: auto;
+ display: inline-block;
+ border-right: 6px solid transparent;
+ border-bottom: 6px solid #fff;
+ border-left: 6px solid transparent;
+ content: '';
+}
+
.daterangepicker.opensright:before {
position: absolute;
top: -7px;
@@ -205,7 +239,7 @@
color: #999;
}
-.daterangepicker td.disabled {
+.daterangepicker td.disabled, .daterangepicker option.disabled {
color: #999;
}
@@ -220,6 +254,24 @@
border-radius: 0;
}
+.daterangepicker td.start-date {
+ -webkit-border-radius: 4px 0 0 4px;
+ -moz-border-radius: 4px 0 0 4px;
+ border-radius: 4px 0 0 4px;
+}
+
+.daterangepicker td.end-date {
+ -webkit-border-radius: 0 4px 4px 0;
+ -moz-border-radius: 0 4px 4px 0;
+ border-radius: 0 4px 4px 0;
+}
+
+.daterangepicker td.start-date.end-date {
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+
.daterangepicker td.active, .daterangepicker td.active:hover {
background-color: #357ebd;
border-color: #3071a9;
@@ -248,7 +300,7 @@
width: 40%;
}
-.daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.ampmselect {
+.daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.secondselect, .daterangepicker select.ampmselect {
width: 50px;
margin-bottom: 0;
}