From 8992ec3d4b4365fa823a62b371fcaf8b20681ee3 Mon Sep 17 00:00:00 2001 From: Adrian Moerchen Date: Wed, 14 Nov 2012 17:15:00 +0100 Subject: [PATCH 1/2] Added ability to set a timezoneoffset and fixed a bug where maxDate was not working --- .gitignore | 2 ++ Source/Picker.Date.js | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 0f6221c..7655965 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.tmp* +/.settings +/.project diff --git a/Source/Picker.Date.js b/Source/Picker.Date.js index fda87ec..44b812a 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()){ @@ -653,7 +654,7 @@ var isUnavailable = function(type, date, options){ month = date.get('month') + 1; day = date.get('date'); - var dateAllow = (minDate && date < minDate) || (minDate && date > maxDate); + var dateAllow = (minDate && date < minDate) || (maxDate && date > maxDate); if (availableDates != null){ dateAllow = dateAllow || availableDates[year] == null From cf48a104f42ecd87ab7f59fbf1386e40e47594d5 Mon Sep 17 00:00:00 2001 From: Adrian Moerchen Date: Thu, 15 Nov 2012 09:06:31 +0100 Subject: [PATCH 2/2] Updated documentation for new timezone offset --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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: