pickadate.js
pickadate.js copied to clipboard
time 24 hours format
I have two pickatime() elements to select a "from" "to" range with the "to" going up to 24:00. But this gets represented as 0:00 and all validations that look for "from < to" fail because of the 0 value.
Any way to have the 24:00 as 24?
I also need a 24:00 hour selection. Is there an easy solution for this?
I've studied the API and found a kind of solution:
button.pickatime({
formatLabel: 'HH:i',
formatSubmit: 'HH:i',
container: '#pickatime-container',
interval: 15,
disable: disables,
onOpen: function() {
this.$node.addClass(_textHighlightClass);
var rootPos = this.$node.offset();
$('#pickatime-container').offset({
top: rootPos.top - 60,
left: rootPos.left + 60
}).find("ul.picker__list li.picker__list-item:last")
.after('<li class="picker__list-item" data-pick="1440" role="option" aria-label="12:00 AM">24:00</li>');
defaultTime = this.get('select', 'HH:i');
},
onSet: function(time) {
if (time.select !== undefined && defaultTime !== this.get('select', 'HH:i')) {
if(this.get('value') === '12:00 AM') {
this.$node.text('24:00');
this.$node.data('value', '24:00');
}
else {
this.$node.text(this.get('select', 'HH:i'));
this.$node.data('value', this.get('select', 'HH:i'));
}
}
},
onClose: function() {
this.$node.removeClass(_textHighlightClass);
this.stop();
}
}).pickatime('picker').open();