vendor/assets/javascripts/pickadate/picker.date.js in pickadate-rails-3.5.3.0 vs vendor/assets/javascripts/pickadate/picker.date.js in pickadate-rails-3.5.4.0

- old
+ new

@@ -1,8 +1,8 @@ /*! - * Date picker for pickadate.js v3.5.3 + * Date picker for pickadate.js v3.5.4 * http://amsul.github.io/pickadate.js/date.htm */ (function ( factory ) { @@ -100,14 +100,14 @@ 38: -7, // Up 39: function() { return isRTL() ? -1 : 1 }, // Right 37: function() { return isRTL() ? 1 : -1 }, // Left go: function( timeChange ) { var highlightedObject = calendar.item.highlight, - targetDate = new Date( highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange ) + targetDate = new Date( Date.UTC(highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange) ) calendar.set( 'highlight', - [ targetDate.getFullYear(), targetDate.getMonth(), targetDate.getDate() ], + targetDate, { interval: timeChange } ) this.render() } } @@ -220,30 +220,35 @@ } // If it’s an array, convert it into a date and make sure // that it’s a valid date – otherwise default to today. else if ( $.isArray( value ) ) { - value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] ) + value = new Date(Date.UTC(value[ 0 ], value[ 1 ], value[ 2 ] )) value = _.isDate( value ) ? value : calendar.create().obj } - // If it’s a number or date object, make a normalized date. - else if ( _.isInteger( value ) || _.isDate( value ) ) { + // If it’s a number, make a normalized date. + else if ( _.isInteger( value ) ) { value = calendar.normalize( new Date( value ), options ) } + // If it’s a date object, make a normalized date. + else if ( _.isDate( value ) ) { + value = calendar.normalize( value, options ) + } + // If it’s a literal true or any other case, set it to now. else /*if ( value === true )*/ { value = calendar.now( type, value, options ) } // Return the compiled object. return { - year: isInfiniteValue || value.getFullYear(), - month: isInfiniteValue || value.getMonth(), - date: isInfiniteValue || value.getDate(), - day: isInfiniteValue || value.getDay(), + year: isInfiniteValue || value.getUTCFullYear(), + month: isInfiniteValue || value.getUTCMonth(), + date: isInfiniteValue || value.getUTCDate(), + day: isInfiniteValue || value.getUTCDay(), obj: isInfiniteValue || value, pick: isInfiniteValue || value.getTime() } } //DatePicker.prototype.create @@ -314,11 +319,11 @@ * Get the date today. */ DatePicker.prototype.now = function( type, value, options ) { value = new Date() if ( options && options.rel ) { - value.setDate( value.getDate() + options.rel ) + value.setUTCDate( value.getUTCDate() + options.rel ) } return this.normalize( value, options ) } @@ -356,17 +361,17 @@ targetYear = viewsetObject.year targetMonth = viewsetObject.month } // Figure out the expected target year and month. - targetDateObject = new Date( targetYear, targetMonth + ( options && options.nav ? options.nav : 0 ), 1 ) - targetYear = targetDateObject.getFullYear() - targetMonth = targetDateObject.getMonth() + targetDateObject = new Date( Date.UTC( targetYear, targetMonth + ( options && options.nav ? options.nav : 0 ), 1 ) ) + targetYear = targetDateObject.getUTCFullYear() + targetMonth = targetDateObject.getUTCMonth() // If the month we’re going to doesn’t have enough days, // keep decreasing the date until we reach the month’s last date. - while ( /*safety &&*/ new Date( targetYear, targetMonth, targetDate ).getMonth() !== targetMonth ) { + while ( /*safety &&*/ new Date( Date.UTC( targetYear, targetMonth, targetDate ) ).getUTCMonth() !== targetMonth ) { targetDate -= 1 /*safety -= 1 if ( !safety ) { throw 'Fell into an infinite loop while navigating to ' + new Date( targetYear, targetMonth, targetDate ) + '.' }*/ @@ -381,11 +386,11 @@ /** * Normalize a date by setting the hours to midnight. */ DatePicker.prototype.normalize = function( value/*, options*/ ) { - value.setHours( 0, 0, 0, 0 ) + value.setUTCHours( 0, 0, 0, 0 ) return value } /** @@ -926,10 +931,10 @@ else if ( $.isArray( unitToEnable ) ) { matchFound = unitToEnable if ( !matchFound[3] ) matchFound.push( 'inverted' ) } else if ( _.isDate( unitToEnable ) ) { - matchFound = [ unitToEnable.getFullYear(), unitToEnable.getMonth(), unitToEnable.getDate(), 'inverted' ] + matchFound = [ unitToEnable.getUTCFullYear(), unitToEnable.getUTCMonth(), unitToEnable.getUTCDate(), 'inverted' ] } break } }