Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timezone offset #129

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.tmp*
/.settings
/.project
*~
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
7 changes: 4 additions & 3 deletions Source/Picker.Date.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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()){
Expand Down