Skip to content

Commit

Permalink
Removed the timezone option, which has not functioned correctly sin…
Browse files Browse the repository at this point in the history
…ce its inception. I recommend managing time zones in your application, or through the moment object, where you can set a global time zone. http://momentjs.com/timezone/docs/
  • Loading branch information
dangrossman committed Oct 7, 2015
1 parent 72705d8 commit 7831c20
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
33 changes: 9 additions & 24 deletions daterangepicker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @version: 2.0.13
* @version: 2.0.14
* @author: Dan Grossman http://www.dangrossman.info/
* @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
Expand Down Expand Up @@ -41,7 +41,6 @@
this.element = $(element);
this.startDate = moment().startOf('day');
this.endDate = moment().endOf('day');
this.timeZone = moment().utcOffset();
this.minDate = false;
this.maxDate = false;
this.dateLimit = false;
Expand Down Expand Up @@ -289,19 +288,6 @@
}
}

// 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') {
if (typeof options.timeZone === 'string' && typeof moment.tz !== 'undefined') {
this.timeZone = moment.tz.zone(options.timeZone).parse(new Date) * -1; // Offset is positive if the timezone is behind UTC and negative if it is ahead.
} else {
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) {

Expand Down Expand Up @@ -452,7 +438,7 @@

setStartDate: function(startDate) {
if (typeof startDate === 'string')
this.startDate = moment(startDate, this.locale.format).utcOffset(this.timeZone);
this.startDate = moment(startDate, this.locale.format);

if (typeof startDate === 'object')
this.startDate = moment(startDate);
Expand All @@ -477,7 +463,7 @@

setEndDate: function(endDate) {
if (typeof endDate === 'string')
this.endDate = moment(endDate, this.locale.format).utcOffset(this.timeZone);
this.endDate = moment(endDate, this.locale.format);

if (typeof endDate === 'object')
this.endDate = moment(endDate);
Expand Down Expand Up @@ -657,8 +643,7 @@
if (dayOfWeek == this.locale.firstDay)
startDay = daysInLastMonth - 6;

// Possible patch for issue #626 https://github.com/dangrossman/bootstrap-daterangepicker/issues/626
var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]).utcOffset(this.timeZone); // .utcOffset(this.timeZone);
var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]);

var col, row;
for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) {
Expand Down Expand Up @@ -1405,8 +1390,8 @@

formInputsChanged: function(e) {
var isRight = $(e.target).closest('.calendar').hasClass('right');
var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format).utcOffset(this.timeZone);
var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format).utcOffset(this.timeZone);
var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format);
var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format);

if (start.isValid() && end.isValid()) {

Expand Down Expand Up @@ -1440,12 +1425,12 @@
end = null;

if (dateString.length === 2) {
start = moment(dateString[0], this.locale.format).utcOffset(this.timeZone);
end = moment(dateString[1], this.locale.format).utcOffset(this.timeZone);
start = moment(dateString[0], this.locale.format);
end = moment(dateString[1], this.locale.format);
}

if (this.singleDatePicker || start === null || end === null) {
start = moment(this.element.val(), this.locale.format).utcOffset(this.timeZone);
start = moment(this.element.val(), this.locale.format);
end = start;
}

Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'dangrossman:bootstrap-daterangepicker',
version: '2.0.13',
version: '2.0.14',
summary: 'Date range picker component for Bootstrap',
git: 'https://github.com/dangrossman/bootstrap-daterangepicker',
documentation: 'README.md'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-daterangepicker",
"version": "2.0.13",
"version": "2.0.14",
"description": "Date range picker component for Bootstrap",
"main": "daterangepicker.js",
"style": "daterangepicker.css",
Expand Down
3 changes: 0 additions & 3 deletions website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,6 @@ <h2>Options</h2>
<li>
<code>dateLimit</code>: (object) The maximum span between the selected start and end dates. Can have any property you can add to a moment object (i.e. days, months)
</li>
<li>
<code>timeZone</code>: (string or number) The timezone that will be used to display the startDate and endDate in the calendar. This may be a string such as "08</code>:00" or an offset in minutes from Greenwich Mean Time. Uses Moment.js #utcOffset, <a href="http://momentjs.com/docs/#/manipulating/utc-offset/">see the docs here</a> for more information. If the timeZone option is not set, the calendar will use the time zone set on the startDate that has been passed in through the options, if it has one. Defaults to the local time zone
</li>
<li>
<code>showDropdowns</code>: (boolean) Show year and month select boxes above calendars to jump to a specific month and year
</li>
Expand Down

0 comments on commit 7831c20

Please sign in to comment.