diff --git a/.gitignore b/.gitignore index 30c9f5c..b619a4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.tmp* +/.settings +/.project *~ diff --git a/README.md b/README.md index 47486c1..957f8e5 100644 --- a/README.md +++ b/README.md @@ -122,8 +122,7 @@ All the options of the Picker and Picker.Attach classes, and: - months_title: (*function*, defaults to a function which returns `date.format('%b %Y')`) A function that returns the title for the monthpicker with as arguments the date object and the options object. - days_title: (*function*, defaults to a function which returns `date.format('%b %Y')`) A function that returns the title for the daypicker with as arguments the date object and the options object. - time_title: (*function*, defaults to a function which returns `(options.pickOnly == 'time') ? Locale.get('DatePicker.select_a_time') : date.format('%d %B, %Y')`) A function that returns the title for the timepicker with as arguments the date object and the options object. - - +- timezoneOffsetInMillis (*number*, defaults to 0) An offset of the currents browser timezone and the users timezone in milliseconds. Can be used to show correct dates if your application works on another timezone than the users browser. ### Events: diff --git a/Source/Picker.Date.js b/Source/Picker.Date.js index 8b4558e..cd34617 100644 --- a/Source/Picker.Date.js +++ b/Source/Picker.Date.js @@ -28,6 +28,7 @@ this.DatePicker = Picker.Date = new Class({ timePicker: false, timePickerOnly: false, // deprecated, use onlyView = 'time' timeWheelStep: 1, // 10,15,20,30 + timezoneOffsetInMillis: 0, yearPicker: true, yearsPerPage: 20, @@ -108,8 +109,8 @@ this.DatePicker = Picker.Date = new Class({ // This is where we store the selected date if (!this.currentView || !options.openLastView) this.currentView = options.startView; - - this.date = limitDate(new Date(), options.minDate, options.maxDate); + + this.date = limitDate(new Date().increment('ms', options.timezoneOffsetInMillis), options.minDate, options.maxDate); var tag = element.get('tag'), input; if (tag == 'input') input = element; else { @@ -124,7 +125,7 @@ this.DatePicker = Picker.Date = new Class({ }, getInputDate: function(input){ - this.date = new Date(); + this.date = new Date().increment('ms', this.options.timezoneOffsetInMillis); if (!input) return; var date = Date.parse(input.get('value')); if (date == null || !date.isValid()){