Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add timezone offset #129

Open
wants to merge 3 commits into from

2 participants

Adrian Mörchen Arian Stolwijk
Adrian Mörchen

We've created a patch with a new option for adding a timezone offset.

Using this enables the calender to show a different date as the current date than the browsers date.

This is useful when your site works on the local time of the current logged in user and not the local time of the users browser.

Adrian Moerchen added some commits
Arian Stolwijk
Owner

Sounds cool, I think a test/demo in the Test folder would be nice so we can test it a little.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 14, 2012
  1. Added ability to set a timezoneoffset and fixed a bug where maxDate w…

    Adrian Moerchen authored
    …as not working
  2. merge

    Adrian Moerchen authored
Commits on Nov 15, 2012
  1. Updated documentation for new timezone offset

    Adrian Moerchen authored
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 5 deletions.
  1. +2 −0  .gitignore
  2. +1 −2  README.md
  3. +4 −3 Source/Picker.Date.js
2  .gitignore
View
@@ -1,2 +1,4 @@
*.tmp*
+/.settings
+/.project
*~
3  README.md
View
@@ -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:
7 Source/Picker.Date.js
View
@@ -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()){
Something went wrong with that request. Please try again.