Skip to content

Commit a4b19dd

Browse files
committed
Add pre-defined formats for ISO 8601
1 parent 3990bbe commit a4b19dd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ $.extend(Timepicker.prototype, {
118118
formattedTime: '',
119119
formattedDateTime: '',
120120
timezoneList: null,
121+
// pre-defined formats for ISO 8601
122+
ISO_8601: 'iso8601', // YYYY-MM-DDThh:mm:ss -> 1999-01-01T23:01:01
123+
ISO_8601Z: 'iso8601z', // YYYY-MM-DDThh:mm:ss(Z|[-+]hh:mm) -> 1999-01-01T23:01:01+01:00
121124

122125
/* Override the default settings for all instances of the time picker.
123126
@param settings object - the new settings to use as defaults (anonymous object)
@@ -163,6 +166,16 @@ $.extend(Timepicker.prototype, {
163166
},
164167
timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
165168
});
169+
170+
// pre-defined formats for ISO 8601
171+
if (o.timeFormat !== undefined && o.timeFormat.match(new RegExp('^'+ this.ISO_8601Z +'?$'))) {
172+
tp_inst._defaults.dateFormat = $.datepicker.ISO_8601;
173+
tp_inst._defaults.separator = 'T';
174+
tp_inst._defaults.timeFormat = (o.timeFormat == this.ISO_8601Z) ? 'hh:mm:ssz' : 'hh:mm:ss';
175+
tp_inst._defaults.ampm = false;
176+
tp_inst._defaults.timezoneIso8609 = true;
177+
}
178+
166179
tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { return val.toUpperCase() });
167180
tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase() });
168181

0 commit comments

Comments
 (0)