formize 1.1.0 → 1.1.1
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.
- data/VERSION +1 -1
- data/lib/assets/javascripts/formize-behave.js +1 -3
- data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +455 -209
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-af.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-bg.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-ca.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-cs.js +3 -2
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-da.js +21 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-de.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-el.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-es.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-et.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-eu.js +21 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-fi.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-fr.js +2 -16
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-gl.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-he.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-hr.js +21 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-hu.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-id.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-it.js +5 -4
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-ja.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-ko.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-lt.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-nl.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-no.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-pl.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-pt-BR.js +17 -16
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-pt.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-ro.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-ru.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-sk.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-sv.js +7 -6
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-th.js +18 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-tr.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-uk.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-vi.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-zh-CN.js +2 -1
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-zh-TW.js +2 -1
- metadata +6 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* jQuery timepicker addon
|
|
3
3
|
* By: Trent Richardson [http://trentrichardson.com]
|
|
4
|
-
* Version 1.
|
|
5
|
-
* Last Modified:
|
|
4
|
+
* Version 1.3.1
|
|
5
|
+
* Last Modified: 07/07/2013
|
|
6
6
|
*
|
|
7
|
-
* Copyright
|
|
7
|
+
* Copyright 2013 Trent Richardson
|
|
8
8
|
* You may use this project under MIT or GPL licenses.
|
|
9
9
|
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
|
|
10
10
|
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
*/
|
|
28
28
|
$.extend($.ui, {
|
|
29
29
|
timepicker: {
|
|
30
|
-
version: "1.
|
|
30
|
+
version: "1.3.1"
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* Settings for (groups of) time pickers are maintained in an instance object,
|
|
38
38
|
* allowing multiple different settings on the same page.
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
var Timepicker = function() {
|
|
41
41
|
this.regional = []; // Available regional settings, indexed by language code
|
|
42
42
|
this.regional[''] = { // Default regional settings
|
|
43
43
|
currentText: 'Now',
|
|
@@ -52,37 +52,41 @@
|
|
|
52
52
|
minuteText: 'Minute',
|
|
53
53
|
secondText: 'Second',
|
|
54
54
|
millisecText: 'Millisecond',
|
|
55
|
+
microsecText: 'Microsecond',
|
|
55
56
|
timezoneText: 'Time Zone',
|
|
56
57
|
isRTL: false
|
|
57
58
|
};
|
|
58
59
|
this._defaults = { // Global defaults for all the datetime picker instances
|
|
59
60
|
showButtonPanel: true,
|
|
60
61
|
timeOnly: false,
|
|
61
|
-
showHour:
|
|
62
|
-
showMinute:
|
|
63
|
-
showSecond:
|
|
64
|
-
showMillisec:
|
|
65
|
-
|
|
62
|
+
showHour: null,
|
|
63
|
+
showMinute: null,
|
|
64
|
+
showSecond: null,
|
|
65
|
+
showMillisec: null,
|
|
66
|
+
showMicrosec: null,
|
|
67
|
+
showTimezone: null,
|
|
66
68
|
showTime: true,
|
|
67
69
|
stepHour: 1,
|
|
68
70
|
stepMinute: 1,
|
|
69
71
|
stepSecond: 1,
|
|
70
72
|
stepMillisec: 1,
|
|
73
|
+
stepMicrosec: 1,
|
|
71
74
|
hour: 0,
|
|
72
75
|
minute: 0,
|
|
73
76
|
second: 0,
|
|
74
77
|
millisec: 0,
|
|
78
|
+
microsec: 0,
|
|
75
79
|
timezone: null,
|
|
76
|
-
useLocalTimezone: false,
|
|
77
|
-
defaultTimezone: "+0000",
|
|
78
80
|
hourMin: 0,
|
|
79
81
|
minuteMin: 0,
|
|
80
82
|
secondMin: 0,
|
|
81
83
|
millisecMin: 0,
|
|
84
|
+
microsecMin: 0,
|
|
82
85
|
hourMax: 23,
|
|
83
86
|
minuteMax: 59,
|
|
84
87
|
secondMax: 59,
|
|
85
88
|
millisecMax: 999,
|
|
89
|
+
microsecMax: 999,
|
|
86
90
|
minDateTime: null,
|
|
87
91
|
maxDateTime: null,
|
|
88
92
|
onSelect: null,
|
|
@@ -90,6 +94,7 @@
|
|
|
90
94
|
minuteGrid: 0,
|
|
91
95
|
secondGrid: 0,
|
|
92
96
|
millisecGrid: 0,
|
|
97
|
+
microsecGrid: 0,
|
|
93
98
|
alwaysSetTime: true,
|
|
94
99
|
separator: ' ',
|
|
95
100
|
altFieldTimeOnly: true,
|
|
@@ -99,7 +104,6 @@
|
|
|
99
104
|
pickerTimeFormat: null,
|
|
100
105
|
pickerTimeSuffix: null,
|
|
101
106
|
showTimepicker: true,
|
|
102
|
-
timezoneIso8601: false,
|
|
103
107
|
timezoneList: null,
|
|
104
108
|
addSliderAccess: false,
|
|
105
109
|
sliderAccessArgs: null,
|
|
@@ -108,7 +112,7 @@
|
|
|
108
112
|
parse: 'strict'
|
|
109
113
|
};
|
|
110
114
|
$.extend(this._defaults, this.regional['']);
|
|
111
|
-
}
|
|
115
|
+
};
|
|
112
116
|
|
|
113
117
|
$.extend(Timepicker.prototype, {
|
|
114
118
|
$input: null,
|
|
@@ -119,27 +123,31 @@
|
|
|
119
123
|
minute_slider: null,
|
|
120
124
|
second_slider: null,
|
|
121
125
|
millisec_slider: null,
|
|
126
|
+
microsec_slider: null,
|
|
122
127
|
timezone_select: null,
|
|
123
128
|
hour: 0,
|
|
124
129
|
minute: 0,
|
|
125
130
|
second: 0,
|
|
126
131
|
millisec: 0,
|
|
132
|
+
microsec: 0,
|
|
127
133
|
timezone: null,
|
|
128
|
-
defaultTimezone: "+0000",
|
|
129
134
|
hourMinOriginal: null,
|
|
130
135
|
minuteMinOriginal: null,
|
|
131
136
|
secondMinOriginal: null,
|
|
132
137
|
millisecMinOriginal: null,
|
|
138
|
+
microsecMinOriginal: null,
|
|
133
139
|
hourMaxOriginal: null,
|
|
134
140
|
minuteMaxOriginal: null,
|
|
135
141
|
secondMaxOriginal: null,
|
|
136
142
|
millisecMaxOriginal: null,
|
|
143
|
+
microsecMaxOriginal: null,
|
|
137
144
|
ampm: '',
|
|
138
145
|
formattedDate: '',
|
|
139
146
|
formattedTime: '',
|
|
140
147
|
formattedDateTime: '',
|
|
141
148
|
timezoneList: null,
|
|
142
|
-
units: ['hour','minute','second','millisec'],
|
|
149
|
+
units: ['hour','minute','second','millisec', 'microsec'],
|
|
150
|
+
support: {},
|
|
143
151
|
control: null,
|
|
144
152
|
|
|
145
153
|
/*
|
|
@@ -155,11 +163,11 @@
|
|
|
155
163
|
/*
|
|
156
164
|
* Create a new Timepicker instance
|
|
157
165
|
*/
|
|
158
|
-
_newInst: function($input,
|
|
166
|
+
_newInst: function($input, opts) {
|
|
159
167
|
var tp_inst = new Timepicker(),
|
|
160
168
|
inlineSettings = {},
|
|
161
|
-
|
|
162
|
-
|
|
169
|
+
fns = {},
|
|
170
|
+
overrides, i;
|
|
163
171
|
|
|
164
172
|
for (var attrName in this._defaults) {
|
|
165
173
|
if(this._defaults.hasOwnProperty(attrName)){
|
|
@@ -173,6 +181,7 @@
|
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
183
|
}
|
|
184
|
+
|
|
176
185
|
overrides = {
|
|
177
186
|
beforeShow: function (input, dp_inst) {
|
|
178
187
|
if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
|
|
@@ -197,10 +206,11 @@
|
|
|
197
206
|
};
|
|
198
207
|
for (i in overrides) {
|
|
199
208
|
if (overrides.hasOwnProperty(i)) {
|
|
200
|
-
fns[i] =
|
|
209
|
+
fns[i] = opts[i] || null;
|
|
201
210
|
}
|
|
202
211
|
}
|
|
203
|
-
|
|
212
|
+
|
|
213
|
+
tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, opts, overrides, {
|
|
204
214
|
evnts:fns,
|
|
205
215
|
timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
|
|
206
216
|
});
|
|
@@ -211,9 +221,15 @@
|
|
|
211
221
|
return val.toUpperCase();
|
|
212
222
|
});
|
|
213
223
|
|
|
224
|
+
// detect which units are supported
|
|
225
|
+
tp_inst.support = detectSupport(
|
|
226
|
+
tp_inst._defaults.timeFormat +
|
|
227
|
+
(tp_inst._defaults.pickerTimeFormat? tp_inst._defaults.pickerTimeFormat:'') +
|
|
228
|
+
(tp_inst._defaults.altTimeFormat? tp_inst._defaults.altTimeFormat:''));
|
|
229
|
+
|
|
214
230
|
// controlType is string - key to our this._controls
|
|
215
231
|
if(typeof(tp_inst._defaults.controlType) === 'string'){
|
|
216
|
-
if(
|
|
232
|
+
if(tp_inst._defaults.controlType == 'slider' && typeof(jQuery.ui.slider) === 'undefined'){
|
|
217
233
|
tp_inst._defaults.controlType = 'select';
|
|
218
234
|
}
|
|
219
235
|
tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType];
|
|
@@ -223,29 +239,39 @@
|
|
|
223
239
|
tp_inst.control = tp_inst._defaults.controlType;
|
|
224
240
|
}
|
|
225
241
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
242
|
+
// prep the timezone options
|
|
243
|
+
var timezoneList = [-720,-660,-600,-570,-540,-480,-420,-360,-300,-270,-240,-210,-180,-120,-60,
|
|
244
|
+
0,60,120,180,210,240,270,300,330,345,360,390,420,480,525,540,570,600,630,660,690,720,765,780,840];
|
|
245
|
+
if (tp_inst._defaults.timezoneList !== null) {
|
|
246
|
+
timezoneList = tp_inst._defaults.timezoneList;
|
|
247
|
+
}
|
|
248
|
+
var tzl=timezoneList.length,tzi=0,tzv=null;
|
|
249
|
+
if (tzl > 0 && typeof timezoneList[0] !== 'object') {
|
|
250
|
+
for(; tzi<tzl; tzi++){
|
|
251
|
+
tzv = timezoneList[tzi];
|
|
252
|
+
timezoneList[tzi] = { value: tzv, label: $.timepicker.timezoneOffsetString(tzv, tp_inst.support.iso8601) };
|
|
235
253
|
}
|
|
236
|
-
tp_inst._defaults.timezoneList = timezoneList;
|
|
237
254
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
tp_inst.
|
|
242
|
-
|
|
243
|
-
tp_inst.
|
|
255
|
+
tp_inst._defaults.timezoneList = timezoneList;
|
|
256
|
+
|
|
257
|
+
// set the default units
|
|
258
|
+
tp_inst.timezone = tp_inst._defaults.timezone !== null? $.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) :
|
|
259
|
+
((new Date()).getTimezoneOffset()*-1);
|
|
260
|
+
tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
|
|
261
|
+
tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
|
|
262
|
+
tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
|
|
263
|
+
tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
|
|
264
|
+
tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin :
|
|
265
|
+
tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second;
|
|
266
|
+
tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin :
|
|
267
|
+
tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
|
|
268
|
+
tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin? tp_inst._defaults.microsecMin :
|
|
269
|
+
tp_inst._defaults.microsec > tp_inst._defaults.microsecMax? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec;
|
|
244
270
|
tp_inst.ampm = '';
|
|
245
271
|
tp_inst.$input = $input;
|
|
246
272
|
|
|
247
|
-
if (
|
|
248
|
-
tp_inst.$altInput = $(
|
|
273
|
+
if (tp_inst._defaults.altField) {
|
|
274
|
+
tp_inst.$altInput = $(tp_inst._defaults.altField).css({
|
|
249
275
|
cursor: 'pointer'
|
|
250
276
|
}).focus(function() {
|
|
251
277
|
$input.trigger("focus");
|
|
@@ -307,7 +333,7 @@
|
|
|
307
333
|
}
|
|
308
334
|
$.extend(this, parseRes.timeObj);
|
|
309
335
|
} catch (err) {
|
|
310
|
-
$.
|
|
336
|
+
$.timepicker.log("Error parsing the date/time string: " + err +
|
|
311
337
|
"\ndate/time string = " + timeString +
|
|
312
338
|
"\ntimeFormat = " + this._defaults.timeFormat +
|
|
313
339
|
"\ndateFormat = " + dp_dateFormat);
|
|
@@ -333,9 +359,12 @@
|
|
|
333
359
|
tp_inst = this,
|
|
334
360
|
litem = '',
|
|
335
361
|
uitem = '',
|
|
362
|
+
show = null,
|
|
336
363
|
max = {},
|
|
337
364
|
gridSize = {},
|
|
338
|
-
size = null
|
|
365
|
+
size = null,
|
|
366
|
+
i=0,
|
|
367
|
+
l=0;
|
|
339
368
|
|
|
340
369
|
// Prevent displaying twice
|
|
341
370
|
if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
|
|
@@ -344,25 +373,27 @@
|
|
|
344
373
|
'<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
|
|
345
374
|
|
|
346
375
|
// Create the markup
|
|
347
|
-
for(
|
|
376
|
+
for(i=0,l=this.units.length; i<l; i++){
|
|
348
377
|
litem = this.units[i];
|
|
349
378
|
uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
|
|
379
|
+
show = o['show'+uitem] !== null? o['show'+uitem] : this.support[litem];
|
|
380
|
+
|
|
350
381
|
// Added by Peter Medeiros:
|
|
351
382
|
// - Figure out what the hour/minute/second max should be based on the step values.
|
|
352
383
|
// - Example: if stepMinute is 15, then minMax is 45.
|
|
353
384
|
max[litem] = parseInt((o[litem+'Max'] - ((o[litem+'Max'] - o[litem+'Min']) % o['step'+uitem])), 10);
|
|
354
385
|
gridSize[litem] = 0;
|
|
355
386
|
|
|
356
|
-
html += '<dt class="ui_tpicker_'+ litem +'_label"' + (
|
|
357
|
-
'<dd class="ui_tpicker_'+ litem +'"><div class="ui_tpicker_'+ litem +'_slider"' + (
|
|
387
|
+
html += '<dt class="ui_tpicker_'+ litem +'_label"' + (show ? '' : noDisplay) + '>' + o[litem +'Text'] + '</dt>' +
|
|
388
|
+
'<dd class="ui_tpicker_'+ litem +'"><div class="ui_tpicker_'+ litem +'_slider"' + (show ? '' : noDisplay) + '></div>';
|
|
358
389
|
|
|
359
|
-
if (
|
|
390
|
+
if (show && o[litem+'Grid'] > 0) {
|
|
360
391
|
html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
|
|
361
392
|
|
|
362
393
|
if(litem == 'hour'){
|
|
363
394
|
for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) {
|
|
364
395
|
gridSize[litem]++;
|
|
365
|
-
var tmph = $.datepicker.formatTime(
|
|
396
|
+
var tmph = $.datepicker.formatTime(this.support.ampm? 'hht':'HH', {hour:h}, o);
|
|
366
397
|
html += '<td data-for="'+litem+'">' + tmph + '</td>';
|
|
367
398
|
}
|
|
368
399
|
}
|
|
@@ -379,8 +410,9 @@
|
|
|
379
410
|
}
|
|
380
411
|
|
|
381
412
|
// Timezone
|
|
382
|
-
|
|
383
|
-
html += '<
|
|
413
|
+
var showTz = o.showTimezone !== null? o.showTimezone : this.support.timezone;
|
|
414
|
+
html += '<dt class="ui_tpicker_timezone_label"' + (showTz ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
|
|
415
|
+
html += '<dd class="ui_tpicker_timezone" ' + (showTz ? '' : noDisplay) + '></dd>';
|
|
384
416
|
|
|
385
417
|
// Create the elements from string
|
|
386
418
|
html += '</dl></div>';
|
|
@@ -393,15 +425,16 @@
|
|
|
393
425
|
}
|
|
394
426
|
|
|
395
427
|
// add sliders, adjust grids, add events
|
|
396
|
-
for(
|
|
428
|
+
for(i=0,l=tp_inst.units.length; i<l; i++){
|
|
397
429
|
litem = tp_inst.units[i];
|
|
398
430
|
uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
|
|
399
|
-
|
|
431
|
+
show = o['show'+uitem] !== null? o['show'+uitem] : this.support[litem];
|
|
432
|
+
|
|
400
433
|
// add the slider
|
|
401
434
|
tp_inst[litem+'_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_'+litem+'_slider'), litem, tp_inst[litem], o[litem+'Min'], max[litem], o['step'+uitem]);
|
|
402
435
|
|
|
403
436
|
// adjust the grid and add click event
|
|
404
|
-
if (
|
|
437
|
+
if (show && o[litem+'Grid'] > 0) {
|
|
405
438
|
size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']);
|
|
406
439
|
$tp.find('.ui_tpicker_'+litem+' table').css({
|
|
407
440
|
width: size + "%",
|
|
@@ -430,8 +463,7 @@
|
|
|
430
463
|
|
|
431
464
|
tp_inst._onTimeChange();
|
|
432
465
|
tp_inst._onSelectHandler();
|
|
433
|
-
})
|
|
434
|
-
.css({
|
|
466
|
+
}).css({
|
|
435
467
|
cursor: 'pointer',
|
|
436
468
|
width: (100 / gridSize[litem]) + '%',
|
|
437
469
|
textAlign: 'center',
|
|
@@ -447,23 +479,22 @@
|
|
|
447
479
|
return $("<option />").val(typeof val == "object" ? val.value : val).text(typeof val == "object" ? val.label : val);
|
|
448
480
|
}));
|
|
449
481
|
if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
|
|
450
|
-
var
|
|
451
|
-
var local_timezone = $.timepicker.timeZoneOffsetString(local_date);
|
|
482
|
+
var local_timezone = (new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12)).getTimezoneOffset()*-1;
|
|
452
483
|
if (local_timezone == this.timezone) {
|
|
453
|
-
|
|
484
|
+
selectLocalTimezone(tp_inst);
|
|
454
485
|
} else {
|
|
455
486
|
this.timezone_select.val(this.timezone);
|
|
456
487
|
}
|
|
457
488
|
} else {
|
|
458
489
|
if (typeof(this.hour) != "undefined" && this.hour !== null && this.hour !== "") {
|
|
459
|
-
this.timezone_select.val(o.
|
|
490
|
+
this.timezone_select.val(o.timezone);
|
|
460
491
|
} else {
|
|
461
|
-
|
|
492
|
+
selectLocalTimezone(tp_inst);
|
|
462
493
|
}
|
|
463
494
|
}
|
|
464
495
|
this.timezone_select.change(function() {
|
|
465
|
-
tp_inst._defaults.useLocalTimezone = false;
|
|
466
496
|
tp_inst._onTimeChange();
|
|
497
|
+
tp_inst._onSelectHandler();
|
|
467
498
|
});
|
|
468
499
|
// End timezone options
|
|
469
500
|
|
|
@@ -512,6 +543,7 @@
|
|
|
512
543
|
}
|
|
513
544
|
// end slideAccess integration
|
|
514
545
|
|
|
546
|
+
tp_inst._limitMinMaxDateTime(this.inst, true);
|
|
515
547
|
}
|
|
516
548
|
},
|
|
517
549
|
|
|
@@ -531,11 +563,12 @@
|
|
|
531
563
|
var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
|
|
532
564
|
minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
|
|
533
565
|
|
|
534
|
-
if (this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null) {
|
|
566
|
+
if (this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null || this.microsecMinOriginal === null) {
|
|
535
567
|
this.hourMinOriginal = o.hourMin;
|
|
536
568
|
this.minuteMinOriginal = o.minuteMin;
|
|
537
569
|
this.secondMinOriginal = o.secondMin;
|
|
538
570
|
this.millisecMinOriginal = o.millisecMin;
|
|
571
|
+
this.microsecMinOriginal = o.microsecMin;
|
|
539
572
|
}
|
|
540
573
|
|
|
541
574
|
if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
|
|
@@ -549,26 +582,36 @@
|
|
|
549
582
|
if (this.second <= this._defaults.secondMin) {
|
|
550
583
|
this.second = this._defaults.secondMin;
|
|
551
584
|
this._defaults.millisecMin = minDateTime.getMilliseconds();
|
|
552
|
-
|
|
553
|
-
if (this.millisec < this._defaults.millisecMin) {
|
|
585
|
+
if(this.millisec <= this._defaults.millisecMin) {
|
|
554
586
|
this.millisec = this._defaults.millisecMin;
|
|
587
|
+
this._defaults.microsecMin = minDateTime.getMicroseconds();
|
|
588
|
+
} else {
|
|
589
|
+
if (this.microsec < this._defaults.microsecMin) {
|
|
590
|
+
this.microsec = this._defaults.microsecMin;
|
|
591
|
+
}
|
|
592
|
+
this._defaults.microsecMin = this.microsecMinOriginal;
|
|
555
593
|
}
|
|
594
|
+
} else {
|
|
556
595
|
this._defaults.millisecMin = this.millisecMinOriginal;
|
|
596
|
+
this._defaults.microsecMin = this.microsecMinOriginal;
|
|
557
597
|
}
|
|
558
598
|
} else {
|
|
559
599
|
this._defaults.secondMin = this.secondMinOriginal;
|
|
560
600
|
this._defaults.millisecMin = this.millisecMinOriginal;
|
|
601
|
+
this._defaults.microsecMin = this.microsecMinOriginal;
|
|
561
602
|
}
|
|
562
603
|
} else {
|
|
563
604
|
this._defaults.minuteMin = this.minuteMinOriginal;
|
|
564
605
|
this._defaults.secondMin = this.secondMinOriginal;
|
|
565
606
|
this._defaults.millisecMin = this.millisecMinOriginal;
|
|
607
|
+
this._defaults.microsecMin = this.microsecMinOriginal;
|
|
566
608
|
}
|
|
567
609
|
} else {
|
|
568
610
|
this._defaults.hourMin = this.hourMinOriginal;
|
|
569
611
|
this._defaults.minuteMin = this.minuteMinOriginal;
|
|
570
612
|
this._defaults.secondMin = this.secondMinOriginal;
|
|
571
613
|
this._defaults.millisecMin = this.millisecMinOriginal;
|
|
614
|
+
this._defaults.microsecMin = this.microsecMinOriginal;
|
|
572
615
|
}
|
|
573
616
|
}
|
|
574
617
|
|
|
@@ -576,11 +619,12 @@
|
|
|
576
619
|
var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
|
|
577
620
|
maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
|
|
578
621
|
|
|
579
|
-
if (this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null) {
|
|
622
|
+
if (this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null || this.millisecMaxOriginal === null) {
|
|
580
623
|
this.hourMaxOriginal = o.hourMax;
|
|
581
624
|
this.minuteMaxOriginal = o.minuteMax;
|
|
582
625
|
this.secondMaxOriginal = o.secondMax;
|
|
583
626
|
this.millisecMaxOriginal = o.millisecMax;
|
|
627
|
+
this.microsecMaxOriginal = o.microsecMax;
|
|
584
628
|
}
|
|
585
629
|
|
|
586
630
|
if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()) {
|
|
@@ -591,25 +635,39 @@
|
|
|
591
635
|
if (this.minute >= this._defaults.minuteMax) {
|
|
592
636
|
this.minute = this._defaults.minuteMax;
|
|
593
637
|
this._defaults.secondMax = maxDateTime.getSeconds();
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
638
|
+
if (this.second >= this._defaults.secondMax) {
|
|
639
|
+
this.second = this._defaults.secondMax;
|
|
640
|
+
this._defaults.millisecMax = maxDateTime.getMilliseconds();
|
|
641
|
+
if (this.millisec >= this._defaults.millisecMax) {
|
|
642
|
+
this.millisec = this._defaults.millisecMax;
|
|
643
|
+
this._defaults.microsecMax = maxDateTime.getMicroseconds();
|
|
644
|
+
} else {
|
|
645
|
+
if (this.microsec > this._defaults.microsecMax) {
|
|
646
|
+
this.microsec = this._defaults.microsecMax;
|
|
647
|
+
}
|
|
648
|
+
this._defaults.microsecMax = this.microsecMaxOriginal;
|
|
649
|
+
}
|
|
650
|
+
} else {
|
|
651
|
+
this._defaults.millisecMax = this.millisecMaxOriginal;
|
|
652
|
+
this._defaults.microsecMax = this.microsecMaxOriginal;
|
|
600
653
|
}
|
|
654
|
+
} else {
|
|
655
|
+
this._defaults.secondMax = this.secondMaxOriginal;
|
|
601
656
|
this._defaults.millisecMax = this.millisecMaxOriginal;
|
|
657
|
+
this._defaults.microsecMax = this.microsecMaxOriginal;
|
|
602
658
|
}
|
|
603
659
|
} else {
|
|
604
660
|
this._defaults.minuteMax = this.minuteMaxOriginal;
|
|
605
661
|
this._defaults.secondMax = this.secondMaxOriginal;
|
|
606
662
|
this._defaults.millisecMax = this.millisecMaxOriginal;
|
|
663
|
+
this._defaults.microsecMax = this.microsecMaxOriginal;
|
|
607
664
|
}
|
|
608
665
|
} else {
|
|
609
666
|
this._defaults.hourMax = this.hourMaxOriginal;
|
|
610
667
|
this._defaults.minuteMax = this.minuteMaxOriginal;
|
|
611
668
|
this._defaults.secondMax = this.secondMaxOriginal;
|
|
612
669
|
this._defaults.millisecMax = this.millisecMaxOriginal;
|
|
670
|
+
this._defaults.microsecMax = this.microsecMaxOriginal;
|
|
613
671
|
}
|
|
614
672
|
}
|
|
615
673
|
|
|
@@ -618,22 +676,27 @@
|
|
|
618
676
|
minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
|
|
619
677
|
secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
|
|
620
678
|
millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10);
|
|
679
|
+
microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10);
|
|
621
680
|
|
|
622
681
|
if (this.hour_slider) {
|
|
623
682
|
this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax });
|
|
624
|
-
this.control.value(this, this.hour_slider, 'hour', this.hour);
|
|
683
|
+
this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour));
|
|
625
684
|
}
|
|
626
685
|
if (this.minute_slider) {
|
|
627
686
|
this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax });
|
|
628
|
-
this.control.value(this, this.minute_slider, 'minute', this.minute);
|
|
687
|
+
this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute));
|
|
629
688
|
}
|
|
630
689
|
if (this.second_slider) {
|
|
631
690
|
this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax });
|
|
632
|
-
this.control.value(this, this.second_slider, 'second', this.second);
|
|
691
|
+
this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond));
|
|
633
692
|
}
|
|
634
693
|
if (this.millisec_slider) {
|
|
635
694
|
this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax });
|
|
636
|
-
this.control.value(this, this.millisec_slider, 'millisec', this.millisec);
|
|
695
|
+
this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec));
|
|
696
|
+
}
|
|
697
|
+
if (this.microsec_slider) {
|
|
698
|
+
this.control.options(this, this.microsec_slider, 'microsec', { min: this._defaults.microsecMin, max: microsecMax });
|
|
699
|
+
this.control.value(this, this.microsec_slider, 'microsec', this.microsec - (this.microsec % this._defaults.stepMicrosec));
|
|
637
700
|
}
|
|
638
701
|
}
|
|
639
702
|
|
|
@@ -648,6 +711,7 @@
|
|
|
648
711
|
minute = (this.minute_slider) ? this.control.value(this, this.minute_slider, 'minute') : false,
|
|
649
712
|
second = (this.second_slider) ? this.control.value(this, this.second_slider, 'second') : false,
|
|
650
713
|
millisec = (this.millisec_slider) ? this.control.value(this, this.millisec_slider, 'millisec') : false,
|
|
714
|
+
microsec = (this.microsec_slider) ? this.control.value(this, this.microsec_slider, 'microsec') : false,
|
|
651
715
|
timezone = (this.timezone_select) ? this.timezone_select.val() : false,
|
|
652
716
|
o = this._defaults,
|
|
653
717
|
pickerTimeFormat = o.pickerTimeFormat || o.timeFormat,
|
|
@@ -665,6 +729,9 @@
|
|
|
665
729
|
if (typeof(millisec) == 'object') {
|
|
666
730
|
millisec = false;
|
|
667
731
|
}
|
|
732
|
+
if (typeof(microsec) == 'object') {
|
|
733
|
+
microsec = false;
|
|
734
|
+
}
|
|
668
735
|
if (typeof(timezone) == 'object') {
|
|
669
736
|
timezone = false;
|
|
670
737
|
}
|
|
@@ -681,14 +748,17 @@
|
|
|
681
748
|
if (millisec !== false) {
|
|
682
749
|
millisec = parseInt(millisec, 10);
|
|
683
750
|
}
|
|
751
|
+
if (microsec !== false) {
|
|
752
|
+
microsec = parseInt(microsec, 10);
|
|
753
|
+
}
|
|
684
754
|
|
|
685
755
|
var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
|
|
686
756
|
|
|
687
757
|
// If the update was done in the input field, the input field should not be updated.
|
|
688
758
|
// If the update was done using the sliders, update the input field.
|
|
689
|
-
var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec
|
|
759
|
+
var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec || microsec != this.microsec
|
|
690
760
|
|| (this.ampm.length > 0 && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
|
|
691
|
-
|| (
|
|
761
|
+
|| (this.timezone !== null && timezone != this.timezone));
|
|
692
762
|
|
|
693
763
|
if (hasChanged) {
|
|
694
764
|
|
|
@@ -704,6 +774,9 @@
|
|
|
704
774
|
if (millisec !== false) {
|
|
705
775
|
this.millisec = millisec;
|
|
706
776
|
}
|
|
777
|
+
if (microsec !== false) {
|
|
778
|
+
this.microsec = microsec;
|
|
779
|
+
}
|
|
707
780
|
if (timezone !== false) {
|
|
708
781
|
this.timezone = timezone;
|
|
709
782
|
}
|
|
@@ -714,7 +787,7 @@
|
|
|
714
787
|
|
|
715
788
|
this._limitMinMaxDateTime(this.inst, true);
|
|
716
789
|
}
|
|
717
|
-
if (
|
|
790
|
+
if (this.support.ampm) {
|
|
718
791
|
this.ampm = ampm;
|
|
719
792
|
}
|
|
720
793
|
|
|
@@ -752,12 +825,20 @@
|
|
|
752
825
|
*/
|
|
753
826
|
_updateDateTime: function(dp_inst) {
|
|
754
827
|
dp_inst = this.inst || dp_inst;
|
|
755
|
-
var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
|
828
|
+
//var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
|
829
|
+
var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay)),
|
|
756
830
|
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
|
|
757
831
|
formatCfg = $.datepicker._getFormatConfig(dp_inst),
|
|
758
832
|
timeAvailable = dt !== null && this.timeDefined;
|
|
759
833
|
this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
|
|
760
834
|
var formattedDateTime = this.formattedDate;
|
|
835
|
+
|
|
836
|
+
// if a slider was changed but datepicker doesn't have a value yet, set it
|
|
837
|
+
if(dp_inst.lastVal===""){
|
|
838
|
+
dp_inst.currentYear=dp_inst.selectedYear;
|
|
839
|
+
dp_inst.currentMonth=dp_inst.selectedMonth;
|
|
840
|
+
dp_inst.currentDay=dp_inst.selectedDay;
|
|
841
|
+
}
|
|
761
842
|
|
|
762
843
|
/*
|
|
763
844
|
* remove following lines to force every changes in date picker to change the input value
|
|
@@ -778,7 +859,7 @@
|
|
|
778
859
|
|
|
779
860
|
if (!this._defaults.showTimepicker) {
|
|
780
861
|
this.$input.val(this.formattedDate);
|
|
781
|
-
} else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
|
|
862
|
+
} else if (this.$altInput && this._defaults.timeOnly === false && this._defaults.altFieldTimeOnly === true) {
|
|
782
863
|
this.$altInput.val(this.formattedTime);
|
|
783
864
|
this.$input.val(this.formattedDate);
|
|
784
865
|
} else if (this.$altInput) {
|
|
@@ -786,12 +867,26 @@
|
|
|
786
867
|
var altFormattedDateTime = '',
|
|
787
868
|
altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
|
|
788
869
|
altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
|
|
870
|
+
|
|
871
|
+
if(!this._defaults.timeOnly){
|
|
872
|
+
if (this._defaults.altFormat){
|
|
873
|
+
altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
|
|
874
|
+
}
|
|
875
|
+
else{
|
|
876
|
+
altFormattedDateTime = this.formattedDate;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
if (altFormattedDateTime){
|
|
880
|
+
altFormattedDateTime += altSeparator;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
789
883
|
|
|
790
|
-
if
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
884
|
+
if(this._defaults.altTimeFormat){
|
|
885
|
+
altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
|
|
886
|
+
}
|
|
887
|
+
else{
|
|
888
|
+
altFormattedDateTime += this.formattedTime + altTimeSuffix;
|
|
889
|
+
}
|
|
795
890
|
this.$altInput.val(altFormattedDateTime);
|
|
796
891
|
} else {
|
|
797
892
|
this.$input.val(formattedDateTime);
|
|
@@ -810,7 +905,7 @@
|
|
|
810
905
|
try {
|
|
811
906
|
$.datepicker._updateDatepicker(inst);
|
|
812
907
|
} catch (err) {
|
|
813
|
-
$.
|
|
908
|
+
$.timepicker.log(err);
|
|
814
909
|
}
|
|
815
910
|
}
|
|
816
911
|
}
|
|
@@ -845,8 +940,9 @@
|
|
|
845
940
|
if(tp_inst._defaults.isRTL){
|
|
846
941
|
if(typeof(opts) == 'string'){
|
|
847
942
|
if(opts == 'min' || opts == 'max'){
|
|
848
|
-
if(val !== undefined)
|
|
943
|
+
if(val !== undefined){
|
|
849
944
|
return obj.slider(opts, val*-1);
|
|
945
|
+
}
|
|
850
946
|
return Math.abs(obj.slider(opts));
|
|
851
947
|
}
|
|
852
948
|
return obj.slider(opts);
|
|
@@ -854,24 +950,29 @@
|
|
|
854
950
|
var min = opts.min,
|
|
855
951
|
max = opts.max;
|
|
856
952
|
opts.min = opts.max = null;
|
|
857
|
-
if(min !== undefined)
|
|
953
|
+
if(min !== undefined){
|
|
858
954
|
opts.max = min * -1;
|
|
859
|
-
|
|
955
|
+
}
|
|
956
|
+
if(max !== undefined){
|
|
860
957
|
opts.min = max * -1;
|
|
958
|
+
}
|
|
861
959
|
return obj.slider(opts);
|
|
862
960
|
}
|
|
863
|
-
if(typeof(opts) == 'string' && val !== undefined)
|
|
961
|
+
if(typeof(opts) == 'string' && val !== undefined){
|
|
864
962
|
return obj.slider(opts, val);
|
|
963
|
+
}
|
|
865
964
|
return obj.slider(opts);
|
|
866
965
|
},
|
|
867
966
|
value: function(tp_inst, obj, unit, val){
|
|
868
967
|
if(tp_inst._defaults.isRTL){
|
|
869
|
-
if(val !== undefined)
|
|
968
|
+
if(val !== undefined){
|
|
870
969
|
return obj.slider('value', val*-1);
|
|
970
|
+
}
|
|
871
971
|
return Math.abs(obj.slider('value'));
|
|
872
972
|
}
|
|
873
|
-
if(val !== undefined)
|
|
973
|
+
if(val !== undefined){
|
|
874
974
|
return obj.slider('value', val);
|
|
975
|
+
}
|
|
875
976
|
return obj.slider('value');
|
|
876
977
|
}
|
|
877
978
|
},
|
|
@@ -879,15 +980,15 @@
|
|
|
879
980
|
select: {
|
|
880
981
|
create: function(tp_inst, obj, unit, val, min, max, step){
|
|
881
982
|
var sel = '<select class="ui-timepicker-select" data-unit="'+ unit +'" data-min="'+ min +'" data-max="'+ max +'" data-step="'+ step +'">',
|
|
882
|
-
|
|
883
|
-
m = 0;
|
|
983
|
+
format = tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat;
|
|
884
984
|
|
|
885
985
|
for(var i=min; i<=max; i+=step){
|
|
886
986
|
sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
|
|
887
|
-
if(unit == 'hour'
|
|
888
|
-
sel += $.datepicker.formatTime(
|
|
889
|
-
|
|
890
|
-
else
|
|
987
|
+
if(unit == 'hour'){
|
|
988
|
+
sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig,'')), {hour:i}, tp_inst._defaults);
|
|
989
|
+
}
|
|
990
|
+
else if(unit == 'millisec' || unit == 'microsec' || i >= 10){ sel += i; }
|
|
991
|
+
else {sel += '0'+ i.toString(); }
|
|
891
992
|
sel += '</option>';
|
|
892
993
|
}
|
|
893
994
|
sel += '</select>';
|
|
@@ -905,17 +1006,19 @@
|
|
|
905
1006
|
var o = {},
|
|
906
1007
|
$t = obj.children('select');
|
|
907
1008
|
if(typeof(opts) == 'string'){
|
|
908
|
-
if(val === undefined)
|
|
1009
|
+
if(val === undefined){
|
|
909
1010
|
return $t.data(opts);
|
|
1011
|
+
}
|
|
910
1012
|
o[opts] = val;
|
|
911
1013
|
}
|
|
912
|
-
else o = opts;
|
|
1014
|
+
else{ o = opts; }
|
|
913
1015
|
return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
|
|
914
1016
|
},
|
|
915
1017
|
value: function(tp_inst, obj, unit, val){
|
|
916
1018
|
var $t = obj.children('select');
|
|
917
|
-
if(val !== undefined)
|
|
1019
|
+
if(val !== undefined){
|
|
918
1020
|
return $t.val(val);
|
|
1021
|
+
}
|
|
919
1022
|
return $t.val();
|
|
920
1023
|
}
|
|
921
1024
|
}
|
|
@@ -975,6 +1078,7 @@
|
|
|
975
1078
|
if (parseRes.timeObj) {
|
|
976
1079
|
var t = parseRes.timeObj;
|
|
977
1080
|
parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
|
|
1081
|
+
parseRes.date.setMicroseconds(t.microsec);
|
|
978
1082
|
}
|
|
979
1083
|
|
|
980
1084
|
return parseRes.date;
|
|
@@ -984,7 +1088,8 @@
|
|
|
984
1088
|
* Public utility to parse time
|
|
985
1089
|
*/
|
|
986
1090
|
$.datepicker.parseTime = function(timeFormat, timeString, options) {
|
|
987
|
-
var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {})
|
|
1091
|
+
var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {}),
|
|
1092
|
+
iso8601 = (timeFormat.replace(/\'.*?\'/g,'').indexOf('Z') !== -1);
|
|
988
1093
|
|
|
989
1094
|
// Strict parse requires the timeString to match the timeFormat exactly
|
|
990
1095
|
var strictParse = function(f, s, o){
|
|
@@ -1006,12 +1111,13 @@
|
|
|
1006
1111
|
|
|
1007
1112
|
// figure out position of time elements.. cause js cant do named captures
|
|
1008
1113
|
var getFormatPositions = function(timeFormat) {
|
|
1009
|
-
var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z|'.*?')/g),
|
|
1114
|
+
var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g),
|
|
1010
1115
|
orders = {
|
|
1011
1116
|
h: -1,
|
|
1012
1117
|
m: -1,
|
|
1013
1118
|
s: -1,
|
|
1014
1119
|
l: -1,
|
|
1120
|
+
c: -1,
|
|
1015
1121
|
t: -1,
|
|
1016
1122
|
z: -1
|
|
1017
1123
|
};
|
|
@@ -1027,12 +1133,14 @@
|
|
|
1027
1133
|
};
|
|
1028
1134
|
|
|
1029
1135
|
var regstr = '^' + f.toString()
|
|
1030
|
-
.replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[
|
|
1136
|
+
.replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) {
|
|
1137
|
+
var ml = match.length;
|
|
1031
1138
|
switch (match.charAt(0).toLowerCase()) {
|
|
1032
|
-
case 'h': return '(\\d?\\d)';
|
|
1033
|
-
case 'm': return '(\\d?\\d)';
|
|
1034
|
-
case 's': return '(\\d?\\d)';
|
|
1139
|
+
case 'h': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
|
|
1140
|
+
case 'm': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
|
|
1141
|
+
case 's': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
|
|
1035
1142
|
case 'l': return '(\\d?\\d?\\d)';
|
|
1143
|
+
case 'c': return '(\\d?\\d?\\d)';
|
|
1036
1144
|
case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
|
|
1037
1145
|
case 't': return getPatternAmpm(o.amNames, o.pmNames);
|
|
1038
1146
|
default: // literal escaped in quotes
|
|
@@ -1051,7 +1159,8 @@
|
|
|
1051
1159
|
hour: 0,
|
|
1052
1160
|
minute: 0,
|
|
1053
1161
|
second: 0,
|
|
1054
|
-
millisec: 0
|
|
1162
|
+
millisec: 0,
|
|
1163
|
+
microsec: 0
|
|
1055
1164
|
};
|
|
1056
1165
|
|
|
1057
1166
|
if (treg) {
|
|
@@ -1086,31 +1195,11 @@
|
|
|
1086
1195
|
if (order.l !== -1) {
|
|
1087
1196
|
resTime.millisec = Number(treg[order.l]);
|
|
1088
1197
|
}
|
|
1198
|
+
if (order.c !== -1) {
|
|
1199
|
+
resTime.microsec = Number(treg[order.c]);
|
|
1200
|
+
}
|
|
1089
1201
|
if (order.z !== -1 && treg[order.z] !== undefined) {
|
|
1090
|
-
|
|
1091
|
-
switch (tz.length) {
|
|
1092
|
-
case 1:
|
|
1093
|
-
// Z
|
|
1094
|
-
tz = o.timezoneIso8601 ? 'Z' : '+0000';
|
|
1095
|
-
break;
|
|
1096
|
-
case 5:
|
|
1097
|
-
// +hhmm
|
|
1098
|
-
if (o.timezoneIso8601) {
|
|
1099
|
-
tz = tz.substring(1) == '0000' ? 'Z' : tz.substring(0, 3) + ':' + tz.substring(3);
|
|
1100
|
-
}
|
|
1101
|
-
break;
|
|
1102
|
-
case 6:
|
|
1103
|
-
// +hh:mm
|
|
1104
|
-
if (!o.timezoneIso8601) {
|
|
1105
|
-
tz = tz == 'Z' || tz.substring(1) == '00:00' ? '+0000' : tz.replace(/:/, '');
|
|
1106
|
-
} else {
|
|
1107
|
-
if (tz.substring(1) == '00:00') {
|
|
1108
|
-
tz = 'Z';
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
break;
|
|
1112
|
-
}
|
|
1113
|
-
resTime.timezone = tz;
|
|
1202
|
+
resTime.timezone = $.timepicker.timezoneOffsetNumber(treg[order.z]);
|
|
1114
1203
|
}
|
|
1115
1204
|
|
|
1116
1205
|
|
|
@@ -1123,12 +1212,23 @@
|
|
|
1123
1212
|
var looseParse = function(f,s,o){
|
|
1124
1213
|
try{
|
|
1125
1214
|
var d = new Date('2012-01-01 '+ s);
|
|
1215
|
+
if(isNaN(d.getTime())){
|
|
1216
|
+
d = new Date('2012-01-01T'+ s);
|
|
1217
|
+
if(isNaN(d.getTime())){
|
|
1218
|
+
d = new Date('01/01/2012 '+ s);
|
|
1219
|
+
if(isNaN(d.getTime())){
|
|
1220
|
+
throw "Unable to parse time with native Date: "+ s;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1126
1225
|
return {
|
|
1127
1226
|
hour: d.getHours(),
|
|
1128
|
-
|
|
1129
|
-
|
|
1227
|
+
minute: d.getMinutes(),
|
|
1228
|
+
second: d.getSeconds(),
|
|
1130
1229
|
millisec: d.getMilliseconds(),
|
|
1131
|
-
|
|
1230
|
+
microsec: d.getMicroseconds(),
|
|
1231
|
+
timezone: d.getTimezoneOffset()*-1
|
|
1132
1232
|
};
|
|
1133
1233
|
}
|
|
1134
1234
|
catch(err){
|
|
@@ -1136,14 +1236,14 @@
|
|
|
1136
1236
|
return strictParse(f,s,o);
|
|
1137
1237
|
}
|
|
1138
1238
|
catch(err2){
|
|
1139
|
-
$.
|
|
1239
|
+
$.timepicker.log("Unable to parse \ntimeString: "+ s +"\ntimeFormat: "+ f);
|
|
1140
1240
|
}
|
|
1141
1241
|
}
|
|
1142
1242
|
return false;
|
|
1143
1243
|
}; // end looseParse
|
|
1144
1244
|
|
|
1145
1245
|
if(typeof o.parse === "function"){
|
|
1146
|
-
return o.parse(timeFormat, timeString, o)
|
|
1246
|
+
return o.parse(timeFormat, timeString, o);
|
|
1147
1247
|
}
|
|
1148
1248
|
if(o.parse === 'loose'){
|
|
1149
1249
|
return looseParse(timeFormat, timeString, o);
|
|
@@ -1165,7 +1265,7 @@
|
|
|
1165
1265
|
minute: 0,
|
|
1166
1266
|
second: 0,
|
|
1167
1267
|
millisec: 0,
|
|
1168
|
-
timezone:
|
|
1268
|
+
timezone: 0
|
|
1169
1269
|
}, time);
|
|
1170
1270
|
|
|
1171
1271
|
var tmptime = format,
|
|
@@ -1176,7 +1276,7 @@
|
|
|
1176
1276
|
ampmName = options.pmNames[0];
|
|
1177
1277
|
}
|
|
1178
1278
|
|
|
1179
|
-
tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[
|
|
1279
|
+
tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|('.*?'|".*?"))/g, function(match) {
|
|
1180
1280
|
switch (match) {
|
|
1181
1281
|
case 'HH':
|
|
1182
1282
|
return ('0' + hour).slice(-2);
|
|
@@ -1196,8 +1296,12 @@
|
|
|
1196
1296
|
return time.second;
|
|
1197
1297
|
case 'l':
|
|
1198
1298
|
return ('00' + time.millisec).slice(-3);
|
|
1299
|
+
case 'c':
|
|
1300
|
+
return ('00' + time.microsec).slice(-3);
|
|
1199
1301
|
case 'z':
|
|
1200
|
-
return time.timezone === null? options.
|
|
1302
|
+
return $.timepicker.timezoneOffsetString(time.timezone === null? options.timezone : time.timezone, false);
|
|
1303
|
+
case 'Z':
|
|
1304
|
+
return $.timepicker.timezoneOffsetString(time.timezone === null? options.timezone : time.timezone, true);
|
|
1201
1305
|
case 'T':
|
|
1202
1306
|
return ampmName.charAt(0).toUpperCase();
|
|
1203
1307
|
case 'TT':
|
|
@@ -1258,12 +1362,6 @@
|
|
|
1258
1362
|
var tp_inst = this._get(inst, 'timepicker');
|
|
1259
1363
|
if (tp_inst) {
|
|
1260
1364
|
tp_inst._addTimePicker(inst);
|
|
1261
|
-
|
|
1262
|
-
if (tp_inst._defaults.useLocalTimezone) { //checks daylight saving with the new date.
|
|
1263
|
-
var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
|
|
1264
|
-
selectLocalTimeZone(tp_inst, date);
|
|
1265
|
-
tp_inst._onTimeChange();
|
|
1266
|
-
}
|
|
1267
1365
|
}
|
|
1268
1366
|
}
|
|
1269
1367
|
};
|
|
@@ -1278,7 +1376,8 @@
|
|
|
1278
1376
|
|
|
1279
1377
|
if (tp_inst) {
|
|
1280
1378
|
if ($.datepicker._get(inst, 'constrainInput')) {
|
|
1281
|
-
var ampm =
|
|
1379
|
+
var ampm = tp_inst.support.ampm,
|
|
1380
|
+
tz = tp_inst._defaults.showTimezone !== null? tp_inst._defaults.showTimezone : tp_inst.support.timezone,
|
|
1282
1381
|
dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
|
|
1283
1382
|
datetimeChars = tp_inst._defaults.timeFormat.toString()
|
|
1284
1383
|
.replace(/[hms]/g, '')
|
|
@@ -1290,7 +1389,7 @@
|
|
|
1290
1389
|
.replace(/t/g, ampm ? 'ap' : '') +
|
|
1291
1390
|
" " + tp_inst._defaults.separator +
|
|
1292
1391
|
tp_inst._defaults.timeSuffix +
|
|
1293
|
-
(
|
|
1392
|
+
(tz ? tp_inst._defaults.timezoneList.join('') : '') +
|
|
1294
1393
|
(tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
|
|
1295
1394
|
dateChars,
|
|
1296
1395
|
chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
|
|
@@ -1320,10 +1419,13 @@
|
|
|
1320
1419
|
altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
|
|
1321
1420
|
|
|
1322
1421
|
altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
|
|
1323
|
-
if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly){
|
|
1324
|
-
if(tp_inst._defaults.altFormat)
|
|
1325
|
-
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat,
|
|
1326
|
-
|
|
1422
|
+
if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null){
|
|
1423
|
+
if(tp_inst._defaults.altFormat){
|
|
1424
|
+
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
|
|
1425
|
+
}
|
|
1426
|
+
else{
|
|
1427
|
+
altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
|
|
1428
|
+
}
|
|
1327
1429
|
}
|
|
1328
1430
|
$(altField).val(altFormattedDateTime);
|
|
1329
1431
|
}
|
|
@@ -1346,7 +1448,7 @@
|
|
|
1346
1448
|
try {
|
|
1347
1449
|
$.datepicker._updateDatepicker(inst);
|
|
1348
1450
|
} catch (err) {
|
|
1349
|
-
$.
|
|
1451
|
+
$.timepicker.log(err);
|
|
1350
1452
|
}
|
|
1351
1453
|
}
|
|
1352
1454
|
}
|
|
@@ -1363,7 +1465,7 @@
|
|
|
1363
1465
|
$dp = inst.dpDiv;
|
|
1364
1466
|
this._base_gotoToday(id);
|
|
1365
1467
|
var tp_inst = this._get(inst, 'timepicker');
|
|
1366
|
-
|
|
1468
|
+
selectLocalTimezone(tp_inst);
|
|
1367
1469
|
var now = new Date();
|
|
1368
1470
|
this._setTime(inst, now);
|
|
1369
1471
|
$('.ui-datepicker-today', $dp).click();
|
|
@@ -1414,6 +1516,7 @@
|
|
|
1414
1516
|
tp_inst.minute = date ? date.getMinutes() : defaults.minute;
|
|
1415
1517
|
tp_inst.second = date ? date.getSeconds() : defaults.second;
|
|
1416
1518
|
tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
|
|
1519
|
+
tp_inst.microsec = date ? date.getMicroseconds() : defaults.microsec;
|
|
1417
1520
|
|
|
1418
1521
|
//check if within min/max times..
|
|
1419
1522
|
tp_inst._limitMinMaxDateTime(inst, true);
|
|
@@ -1442,8 +1545,10 @@
|
|
|
1442
1545
|
tp_inst._parseTime(date, withDate);
|
|
1443
1546
|
tp_date = new Date();
|
|
1444
1547
|
tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
|
|
1548
|
+
tp_date.setMicroseconds(tp_inst.microsec);
|
|
1445
1549
|
} else {
|
|
1446
1550
|
tp_date = new Date(date.getTime());
|
|
1551
|
+
tp_date.setMicroseconds(date.getMicroseconds());
|
|
1447
1552
|
}
|
|
1448
1553
|
if (tp_date.toString() == 'Invalid Date') {
|
|
1449
1554
|
tp_date = undefined;
|
|
@@ -1464,7 +1569,34 @@
|
|
|
1464
1569
|
return;
|
|
1465
1570
|
}
|
|
1466
1571
|
|
|
1467
|
-
|
|
1572
|
+
if(typeof(date) === 'string'){
|
|
1573
|
+
date = new Date(date);
|
|
1574
|
+
if(!date.getTime()){
|
|
1575
|
+
$.timepicker.log("Error creating Date object from string.");
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
var tp_inst = this._get(inst, 'timepicker');
|
|
1580
|
+
var tp_date;
|
|
1581
|
+
if (date instanceof Date) {
|
|
1582
|
+
tp_date = new Date(date.getTime());
|
|
1583
|
+
tp_date.setMicroseconds(date.getMicroseconds());
|
|
1584
|
+
} else {
|
|
1585
|
+
tp_date = date;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
// This is important if you are using the timezone option, javascript's Date
|
|
1589
|
+
// object will only return the timezone offset for the current locale, so we
|
|
1590
|
+
// adjust it accordingly. If not using timezone option this won't matter..
|
|
1591
|
+
// If a timezone is different in tp, keep the timezone as is
|
|
1592
|
+
if(tp_inst){
|
|
1593
|
+
// look out for DST if tz wasn't specified
|
|
1594
|
+
if(!tp_inst.support.timezone && tp_inst._defaults.timezone === null){
|
|
1595
|
+
tp_inst.timezone = tp_date.getTimezoneOffset()*-1;
|
|
1596
|
+
}
|
|
1597
|
+
date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
|
|
1598
|
+
tp_date = $.timepicker.timezoneAdjust(tp_date, tp_inst.timezone);
|
|
1599
|
+
}
|
|
1468
1600
|
|
|
1469
1601
|
this._updateDatepicker(inst);
|
|
1470
1602
|
this._base_setDateDatepicker.apply(this, arguments);
|
|
@@ -1492,6 +1624,18 @@
|
|
|
1492
1624
|
var date = this._getDate(inst);
|
|
1493
1625
|
if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) {
|
|
1494
1626
|
date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
|
|
1627
|
+
date.setMicroseconds(tp_inst.microsec);
|
|
1628
|
+
|
|
1629
|
+
// This is important if you are using the timezone option, javascript's Date
|
|
1630
|
+
// object will only return the timezone offset for the current locale, so we
|
|
1631
|
+
// adjust it accordingly. If not using timezone option this won't matter..
|
|
1632
|
+
if(tp_inst.timezone != null){
|
|
1633
|
+
// look out for DST if tz wasn't specified
|
|
1634
|
+
if(!tp_inst.support.timezone && tp_inst._defaults.timezone === null){
|
|
1635
|
+
tp_inst.timezone = date.getTimezoneOffset()*-1;
|
|
1636
|
+
}
|
|
1637
|
+
date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
|
|
1638
|
+
}
|
|
1495
1639
|
}
|
|
1496
1640
|
return date;
|
|
1497
1641
|
}
|
|
@@ -1511,8 +1655,12 @@
|
|
|
1511
1655
|
// Hack! The error message ends with a colon, a space, and
|
|
1512
1656
|
// the "extra" characters. We rely on that instead of
|
|
1513
1657
|
// attempting to perfectly reproduce the parsing algorithm.
|
|
1514
|
-
|
|
1515
|
-
|
|
1658
|
+
if (err.indexOf(":") >= 0) {
|
|
1659
|
+
date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
|
|
1660
|
+
$.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
|
|
1661
|
+
} else {
|
|
1662
|
+
throw err;
|
|
1663
|
+
}
|
|
1516
1664
|
}
|
|
1517
1665
|
return date;
|
|
1518
1666
|
};
|
|
@@ -1612,6 +1760,7 @@
|
|
|
1612
1760
|
}
|
|
1613
1761
|
return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
|
|
1614
1762
|
};
|
|
1763
|
+
|
|
1615
1764
|
/*
|
|
1616
1765
|
* jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
|
|
1617
1766
|
* it will return false for all objects
|
|
@@ -1640,11 +1789,24 @@
|
|
|
1640
1789
|
};
|
|
1641
1790
|
|
|
1642
1791
|
/*
|
|
1643
|
-
* Determine by the time format
|
|
1644
|
-
* Returns
|
|
1792
|
+
* Determine by the time format which units are supported
|
|
1793
|
+
* Returns an object of booleans for each unit
|
|
1645
1794
|
*/
|
|
1646
|
-
var
|
|
1647
|
-
|
|
1795
|
+
var detectSupport = function(timeFormat){
|
|
1796
|
+
var tf = timeFormat.replace(/\'.*?\'/g,'').toLowerCase(), // removes literals
|
|
1797
|
+
isIn = function(f, t){ // does the format contain the token?
|
|
1798
|
+
return f.indexOf(t) !== -1? true:false;
|
|
1799
|
+
};
|
|
1800
|
+
return {
|
|
1801
|
+
hour: isIn(tf,'h'),
|
|
1802
|
+
minute: isIn(tf,'m'),
|
|
1803
|
+
second: isIn(tf,'s'),
|
|
1804
|
+
millisec: isIn(tf,'l'),
|
|
1805
|
+
microsec: isIn(tf,'c'),
|
|
1806
|
+
timezone: isIn(tf,'z'),
|
|
1807
|
+
ampm: isIn(tf,'t') && isIn(timeFormat,'h'),
|
|
1808
|
+
iso8601: isIn(timeFormat, 'Z')
|
|
1809
|
+
};
|
|
1648
1810
|
};
|
|
1649
1811
|
|
|
1650
1812
|
/*
|
|
@@ -1656,7 +1818,7 @@
|
|
|
1656
1818
|
hour = hour - 12;
|
|
1657
1819
|
}
|
|
1658
1820
|
|
|
1659
|
-
if (hour
|
|
1821
|
+
if (hour === 0) {
|
|
1660
1822
|
hour = 12;
|
|
1661
1823
|
}
|
|
1662
1824
|
|
|
@@ -1687,7 +1849,7 @@
|
|
|
1687
1849
|
}
|
|
1688
1850
|
|
|
1689
1851
|
} catch (err) {
|
|
1690
|
-
$.
|
|
1852
|
+
$.timepicker.log('Could not split the date from the time. Please check the following datetimepicker options' +
|
|
1691
1853
|
"\nthrown error: " + err +
|
|
1692
1854
|
"\ndateTimeString" + dateTimeString +
|
|
1693
1855
|
"\ndateFormat = " + dateFormat +
|
|
@@ -1714,7 +1876,7 @@
|
|
|
1714
1876
|
* Internal function to parse datetime interval
|
|
1715
1877
|
* Returns: {date: Date, timeObj: Object}, where
|
|
1716
1878
|
* date - parsed date without time (type Date)
|
|
1717
|
-
* timeObj = {hour: , minute: , second: , millisec: } - parsed time. Optional
|
|
1879
|
+
* timeObj = {hour: , minute: , second: , millisec: , microsec: } - parsed time. Optional
|
|
1718
1880
|
*/
|
|
1719
1881
|
var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
|
|
1720
1882
|
var date;
|
|
@@ -1741,15 +1903,10 @@
|
|
|
1741
1903
|
/*
|
|
1742
1904
|
* Internal function to set timezone_select to the local timezone
|
|
1743
1905
|
*/
|
|
1744
|
-
var
|
|
1906
|
+
var selectLocalTimezone = function(tp_inst, date) {
|
|
1745
1907
|
if (tp_inst && tp_inst.timezone_select) {
|
|
1746
|
-
tp_inst._defaults.useLocalTimezone = true;
|
|
1747
1908
|
var now = typeof date !== 'undefined' ? date : new Date();
|
|
1748
|
-
|
|
1749
|
-
if (tp_inst._defaults.timezoneIso8601) {
|
|
1750
|
-
tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
|
|
1751
|
-
}
|
|
1752
|
-
tp_inst.timezone_select.val(tzoffset);
|
|
1909
|
+
tp_inst.timezone_select.val(now.getTimezoneOffset()*-1);
|
|
1753
1910
|
}
|
|
1754
1911
|
};
|
|
1755
1912
|
|
|
@@ -1760,14 +1917,60 @@
|
|
|
1760
1917
|
|
|
1761
1918
|
/**
|
|
1762
1919
|
* Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
|
|
1763
|
-
* @param
|
|
1920
|
+
* @param number if not a number this value is returned
|
|
1921
|
+
* @param boolean if true formats in accordance to iso8601 "+12:45"
|
|
1764
1922
|
* @return string
|
|
1765
1923
|
*/
|
|
1766
|
-
$.timepicker.
|
|
1767
|
-
|
|
1924
|
+
$.timepicker.timezoneOffsetString = function(tzMinutes, iso8601) {
|
|
1925
|
+
if(isNaN(tzMinutes) || tzMinutes > 840){
|
|
1926
|
+
return tzMinutes;
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
var off = tzMinutes,
|
|
1768
1930
|
minutes = off % 60,
|
|
1769
|
-
hours = (off - minutes) / 60
|
|
1770
|
-
|
|
1931
|
+
hours = (off - minutes) / 60,
|
|
1932
|
+
iso = iso8601? ':':'',
|
|
1933
|
+
tz = (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).slice(-2) + iso + ('0' + (minutes * 101).toString()).slice(-2);
|
|
1934
|
+
|
|
1935
|
+
if(tz == '+00:00'){
|
|
1936
|
+
return 'Z';
|
|
1937
|
+
}
|
|
1938
|
+
return tz;
|
|
1939
|
+
};
|
|
1940
|
+
|
|
1941
|
+
/**
|
|
1942
|
+
* Get the number in minutes that represents a timezone string
|
|
1943
|
+
* @param string formated like "+0500", "-1245"
|
|
1944
|
+
* @return number
|
|
1945
|
+
*/
|
|
1946
|
+
$.timepicker.timezoneOffsetNumber = function(tzString) {
|
|
1947
|
+
tzString = tzString.toString().replace(':',''); // excuse any iso8601, end up with "+1245"
|
|
1948
|
+
|
|
1949
|
+
if(tzString.toUpperCase() === 'Z'){ // if iso8601 with Z, its 0 minute offset
|
|
1950
|
+
return 0;
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
if(!/^(\-|\+)\d{4}$/.test(tzString)){ // possibly a user defined tz, so just give it back
|
|
1954
|
+
return tzString;
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
return ((tzString.substr(0,1) =='-'? -1 : 1) * // plus or minus
|
|
1958
|
+
((parseInt(tzString.substr(1,2),10)*60) + // hours (converted to minutes)
|
|
1959
|
+
parseInt(tzString.substr(3,2),10))); // minutes
|
|
1960
|
+
};
|
|
1961
|
+
|
|
1962
|
+
/**
|
|
1963
|
+
* No way to set timezone in js Date, so we must adjust the minutes to compensate. (think setDate, getDate)
|
|
1964
|
+
* @param date
|
|
1965
|
+
* @param string formated like "+0500", "-1245"
|
|
1966
|
+
* @return date
|
|
1967
|
+
*/
|
|
1968
|
+
$.timepicker.timezoneAdjust = function(date, toTimezone) {
|
|
1969
|
+
var toTz = $.timepicker.timezoneOffsetNumber(toTimezone);
|
|
1970
|
+
if(!isNaN(toTz)){
|
|
1971
|
+
date.setMinutes(date.getMinutes()*1 + (date.getTimezoneOffset()*-1 - toTz*1) );
|
|
1972
|
+
}
|
|
1973
|
+
return date;
|
|
1771
1974
|
};
|
|
1772
1975
|
|
|
1773
1976
|
/**
|
|
@@ -1793,8 +1996,8 @@
|
|
|
1793
1996
|
* @param string method Can be used to specify the type of picker to be added
|
|
1794
1997
|
* @return jQuery
|
|
1795
1998
|
*/
|
|
1796
|
-
$.timepicker.
|
|
1797
|
-
$.timepicker.
|
|
1999
|
+
$.timepicker.datetimeRange = function(startTime, endTime, options) {
|
|
2000
|
+
$.timepicker.handleRange('datetimepicker', startTime, endTime, options);
|
|
1798
2001
|
};
|
|
1799
2002
|
|
|
1800
2003
|
/**
|
|
@@ -1804,12 +2007,10 @@
|
|
|
1804
2007
|
* @param Element endTime
|
|
1805
2008
|
* @param obj options Options for the `timepicker()` call. Also supports `reformat`,
|
|
1806
2009
|
* a boolean value that can be used to reformat the input values to the `dateFormat`.
|
|
1807
|
-
* @param string method Can be used to specify the type of picker to be added
|
|
1808
2010
|
* @return jQuery
|
|
1809
2011
|
*/
|
|
1810
|
-
$.timepicker.dateRange = function(startTime, endTime, options
|
|
1811
|
-
|
|
1812
|
-
$.timepicker.handleRange(method, startTime, endTime, options);
|
|
2012
|
+
$.timepicker.dateRange = function(startTime, endTime, options) {
|
|
2013
|
+
$.timepicker.handleRange('datepicker', startTime, endTime, options);
|
|
1813
2014
|
};
|
|
1814
2015
|
|
|
1815
2016
|
/**
|
|
@@ -1823,60 +2024,105 @@
|
|
|
1823
2024
|
* @return jQuery
|
|
1824
2025
|
*/
|
|
1825
2026
|
$.timepicker.handleRange = function(method, startTime, endTime, options) {
|
|
2027
|
+
options = $.extend({}, {
|
|
2028
|
+
minInterval: 0, // min allowed interval in milliseconds
|
|
2029
|
+
maxInterval: 0, // max allowed interval in milliseconds
|
|
2030
|
+
start: {}, // options for start picker
|
|
2031
|
+
end: {} // options for end picker
|
|
2032
|
+
}, options);
|
|
2033
|
+
|
|
1826
2034
|
$.fn[method].call(startTime, $.extend({
|
|
1827
2035
|
onClose: function(dateText, inst) {
|
|
1828
|
-
checkDates(this, endTime
|
|
2036
|
+
checkDates($(this), endTime);
|
|
1829
2037
|
},
|
|
1830
2038
|
onSelect: function(selectedDateTime) {
|
|
1831
|
-
selected(this, endTime, 'minDate');
|
|
2039
|
+
selected($(this), endTime, 'minDate');
|
|
1832
2040
|
}
|
|
1833
2041
|
}, options, options.start));
|
|
1834
2042
|
$.fn[method].call(endTime, $.extend({
|
|
1835
2043
|
onClose: function(dateText, inst) {
|
|
1836
|
-
checkDates(this, startTime
|
|
2044
|
+
checkDates($(this), startTime);
|
|
1837
2045
|
},
|
|
1838
2046
|
onSelect: function(selectedDateTime) {
|
|
1839
|
-
selected(this, startTime, 'maxDate');
|
|
2047
|
+
selected($(this), startTime, 'maxDate');
|
|
1840
2048
|
}
|
|
1841
2049
|
}, options, options.end));
|
|
1842
|
-
// timepicker doesn't provide access to its 'timeFormat' option,
|
|
1843
|
-
// nor could I get datepicker.formatTime() to behave with times, so I
|
|
1844
|
-
// have disabled reformatting for timepicker
|
|
1845
|
-
if (method != 'timepicker' && options.reformat) {
|
|
1846
|
-
$([startTime, endTime]).each(function() {
|
|
1847
|
-
var format = $(this)[method].call($(this), 'option', 'dateFormat'),
|
|
1848
|
-
date = new Date($(this).val());
|
|
1849
|
-
if ($(this).val() && date) {
|
|
1850
|
-
$(this).val($.datepicker.formatDate(format, date));
|
|
1851
|
-
}
|
|
1852
|
-
});
|
|
1853
|
-
}
|
|
1854
|
-
checkDates(startTime, endTime, startTime.val());
|
|
1855
2050
|
|
|
1856
|
-
|
|
1857
|
-
if (other.val() && (new Date(startTime.val()) > new Date(endTime.val()))) {
|
|
1858
|
-
other.val(dateText);
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
2051
|
+
checkDates(startTime, endTime);
|
|
1861
2052
|
selected(startTime, endTime, 'minDate');
|
|
1862
2053
|
selected(endTime, startTime, 'maxDate');
|
|
1863
2054
|
|
|
2055
|
+
function checkDates(changed, other) {
|
|
2056
|
+
var startdt = startTime[method]('getDate'),
|
|
2057
|
+
enddt = endTime[method]('getDate'),
|
|
2058
|
+
changeddt = changed[method]('getDate');
|
|
2059
|
+
|
|
2060
|
+
if(startdt !== null){
|
|
2061
|
+
var minDate = new Date(startdt.getTime()),
|
|
2062
|
+
maxDate = new Date(startdt.getTime());
|
|
2063
|
+
|
|
2064
|
+
minDate.setMilliseconds(minDate.getMilliseconds() + options.minInterval);
|
|
2065
|
+
maxDate.setMilliseconds(maxDate.getMilliseconds() + options.maxInterval);
|
|
2066
|
+
|
|
2067
|
+
if(options.minInterval > 0 && minDate > enddt){ // minInterval check
|
|
2068
|
+
endTime[method]('setDate',minDate);
|
|
2069
|
+
}
|
|
2070
|
+
else if(options.maxInterval > 0 && maxDate < enddt){ // max interval check
|
|
2071
|
+
endTime[method]('setDate',maxDate);
|
|
2072
|
+
}
|
|
2073
|
+
else if (startdt > enddt) {
|
|
2074
|
+
other[method]('setDate',changeddt);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
|
|
1864
2079
|
function selected(changed, other, option) {
|
|
1865
|
-
if (
|
|
2080
|
+
if (!changed.val()) {
|
|
1866
2081
|
return;
|
|
1867
2082
|
}
|
|
1868
|
-
var date =
|
|
1869
|
-
|
|
2083
|
+
var date = changed[method].call(changed, 'getDate');
|
|
2084
|
+
if(date !== null && options.minInterval > 0){
|
|
2085
|
+
if(option == 'minDate'){
|
|
2086
|
+
date.setMilliseconds(date.getMilliseconds() + options.minInterval);
|
|
2087
|
+
}
|
|
2088
|
+
if(option == 'maxDate'){
|
|
2089
|
+
date.setMilliseconds(date.getMilliseconds() - options.minInterval);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
1870
2092
|
if (date.getTime) {
|
|
1871
|
-
|
|
2093
|
+
other[method].call(other, 'option', option, date);
|
|
1872
2094
|
}
|
|
1873
2095
|
}
|
|
1874
2096
|
return $([startTime.get(0), endTime.get(0)]);
|
|
1875
2097
|
};
|
|
1876
2098
|
|
|
2099
|
+
/**
|
|
2100
|
+
* Log error or data to the console during error or debugging
|
|
2101
|
+
* @param Object err pass any type object to log to the console during error or debugging
|
|
2102
|
+
* @return void
|
|
2103
|
+
*/
|
|
2104
|
+
$.timepicker.log = function(err){
|
|
2105
|
+
if(window.console){
|
|
2106
|
+
console.log(err);
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
2109
|
+
|
|
2110
|
+
/*
|
|
2111
|
+
* Microsecond support
|
|
2112
|
+
*/
|
|
2113
|
+
if(!Date.prototype.getMicroseconds){
|
|
2114
|
+
Date.prototype.microseconds = 0;
|
|
2115
|
+
Date.prototype.getMicroseconds = function(){ return this.microseconds; };
|
|
2116
|
+
Date.prototype.setMicroseconds = function(m){
|
|
2117
|
+
this.setMilliseconds(this.getMilliseconds() + Math.floor(m/1000));
|
|
2118
|
+
this.microseconds = m%1000;
|
|
2119
|
+
return this;
|
|
2120
|
+
};
|
|
2121
|
+
}
|
|
2122
|
+
|
|
1877
2123
|
/*
|
|
1878
2124
|
* Keep up with the version
|
|
1879
2125
|
*/
|
|
1880
|
-
$.timepicker.version = "1.
|
|
2126
|
+
$.timepicker.version = "1.3.1";
|
|
1881
2127
|
|
|
1882
|
-
})(jQuery);
|
|
2128
|
+
})(jQuery);
|