will_pickdate 0.9.8 → 0.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,8 @@
26
26
  // the right might have a different margin
27
27
  timePicker: true,
28
28
  timePickerOnly: false,
29
+ klass: Date,
30
+ timezone: null,
29
31
  yearPicker: true,
30
32
  militaryTime: false,
31
33
  yearsPerPage: 20,
@@ -49,7 +51,10 @@
49
51
  }, options);
50
52
 
51
53
  if(!this.options.initializeDate) {
52
- this.options.initializeDate = new Date();
54
+ this.options.initializeDate = new this.options.klass();
55
+ if(this.options.timezone) {
56
+ this.options.initializeDate.setTimezone(this.options.timezone);
57
+ }
53
58
  }
54
59
 
55
60
  if(this.options.toggleElements != null && this.options.toggleElements.jquery) {
@@ -69,8 +74,11 @@
69
74
  }
70
75
 
71
76
  if(init_clone_val = this.element.val()) {
72
- init_clone_val = this.format(new Date(this.unformat(init_clone_val, this.options.inputOutputFormat)),
73
- this.options.format);
77
+ if(this.options.timezone) {
78
+ init_clone_val = this.format(new this.options.klass(this.unformat(init_clone_val, this.options.inputOutputFormat), this.options.timezone), this.options.format);
79
+ } else {
80
+ init_clone_val = this.format(new this.options.klass(this.unformat(init_clone_val, this.options.inputOutputFormat)), this.options.format);
81
+ }
74
82
  }
75
83
  else if(!this.options.allowEmpty) {
76
84
  init_clone_val = this.format(this.options.initializeDate, this.options.format);
@@ -98,14 +106,32 @@
98
106
  // $('#event_starts_at').change(function(e){ $('#event_ends_at').val(this.value).change() })
99
107
  // in order to control through outside behaviours the value and display value of the calendar widget
100
108
  this.element.change($.proxy(function(e) {
101
- this.clone.val(
102
- this.format(
103
- new Date(
104
- this.unformat(
105
- this.element.val(),
106
- this.options.inputOutputFormat)
107
- ),
108
- this.options.format));
109
+ if(this.options.timezone){
110
+ this.clone.val(
111
+ this.format(
112
+ new this.options.klass(
113
+ this.unformat(
114
+ this.element.val(),
115
+ this.options.inputOutputFormat
116
+ ),
117
+ this.options.timezone
118
+ ),
119
+ this.options.format
120
+ )
121
+ );
122
+ }else {
123
+ this.clone.val(
124
+ this.format(
125
+ new this.options.klass(
126
+ this.unformat(
127
+ this.element.val(),
128
+ this.options.inputOutputFormat
129
+ )
130
+ ),
131
+ this.options.format
132
+ )
133
+ );
134
+ }
109
135
  }, this));
110
136
 
111
137
  if(this.toggler) {
@@ -149,10 +175,18 @@
149
175
  else {
150
176
  init_visual_date = this.options.initializeDate;
151
177
  if(this.options.maxDate && init_visual_date.valueOf() > this.options.maxDate.valueOf()) {
152
- init_visual_date = new Date(this.options.maxDate.valueOf());
178
+ if(this.options.timezone) {
179
+ init_visual_date = new this.options.klass(this.options.maxDate.valueOf(), this.options.timezone);
180
+ } else {
181
+ init_visual_date = new this.options.klass(this.options.maxDate.valueOf());
182
+ }
153
183
  }
154
184
  if(this.options.minDate && init_visual_date.valueOf() < this.options.minDate.valueOf()) {
155
- init_visual_date = new Date(this.options.minDate.valueOf());
185
+ if(this.options.timezone) {
186
+ init_visual_date = new this.options.klass(this.options.minDate.valueOf(), this.options.timezone);
187
+ } else {
188
+ init_visual_date = new this.options.klass(this.options.minDate.valueOf());
189
+ }
156
190
  }
157
191
  }
158
192
 
@@ -223,7 +257,11 @@
223
257
  show: function(timestamp) {
224
258
  this.formatMinMaxDates();
225
259
  if(timestamp) {
226
- this.working_date = new Date(timestamp);
260
+ if(this.options.timezone) {
261
+ this.working_date = new this.options.klass(timestamp, this.options.timezone);
262
+ } else {
263
+ this.working_date = new this.options.klass(timestamp);
264
+ }
227
265
  }
228
266
  else {
229
267
  this.working_date = this.options.initializeDate;
@@ -251,7 +289,13 @@
251
289
  this.newContents.empty();
252
290
  }
253
291
 
254
- var startDate = new Date(this.working_date.getTime());
292
+ var startDate;
293
+ if(this.options.timezone) {
294
+ startDate = new this.options.klass(this.working_date.getTime(), this.options.timezone);
295
+ } else {
296
+ startDate = new this.options.klass(this.working_date.getTime());
297
+ }
298
+
255
299
  this.limit = { right: false, left: false };
256
300
 
257
301
  switch(this.mode) {
@@ -846,8 +890,19 @@
846
890
  case 'h': if (a['a'] == 'pm' || a['A'] == 'PM') { d.setHours(v == 12 ? 0 : parseInt(v, 10) + 12); } else { d.setHours(v); } break;
847
891
  case 'i': d.setMinutes(v); break;
848
892
  case 's': d.setSeconds(v); break;
849
- case 'U': d = new Date(parseInt(v, 10) * 1000); break;
850
- case 'S': d = new Date(v);
893
+ case 'U':
894
+ if (this.options.timezone) {
895
+ d = new this.options.klass(parseInt(v, 10) * 1000, this.options.timezone);
896
+ } else {
897
+ d = new this.options.klass(parseInt(v, 10) * 1000);
898
+ }
899
+ break;
900
+ case 'S':
901
+ if (this.options.timezone) {
902
+ d = new this.options.klass(v, this.options.timezone);
903
+ } else {
904
+ d = new this.options.klass(v);
905
+ }
851
906
  }
852
907
  }
853
908
 
@@ -1,3 +1,3 @@
1
1
  module WillPickdate
2
- VERSION = "0.9.8"
2
+ VERSION = "0.9.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: will_pickdate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-21 00:00:00.000000000 Z
12
+ date: 2013-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake