Skip to content
Open
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
14 changes: 9 additions & 5 deletions jquery.timeentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ function TimeEntry() {
// for repeats on the spinner buttons
beforeShow: null, // Function that takes an input field and
// returns a set of custom settings for the time entry
beforeSetTime: null // Function that runs before updating the time,
beforeSetTime: null, // Function that runs before updating the time,
// takes the old and new times, and minimum and maximum times as parameters,
// and returns an adjusted time if necessary
hourLeadingZero: true // True to use a leading zero before hours, false to use a space.
};
$.extend(this._defaults, this.regional['']);
}
Expand Down Expand Up @@ -656,7 +657,7 @@ $.extend(TimeEntry.prototype, {
@param inst (object) the instance settings */
_showTime: function(inst) {
var currentTime = (this._formatNumber(inst.options.show24Hours ? inst._selectedHour :
((inst._selectedHour + 11) % 12) + 1) + inst.options.separator +
((inst._selectedHour + 11) % 12) + 1, inst.options.hourLeadingZero) + inst.options.separator +
this._formatNumber(inst._selectedMinute) +
(inst.options.showSeconds ? inst.options.separator +
this._formatNumber(inst._selectedSecond) : '') +
Expand Down Expand Up @@ -692,11 +693,14 @@ $.extend(TimeEntry.prototype, {
}
},

/* Ensure displayed single number has a leading zero.
/* Ensure displayed single number has a leading zero or space.
@param value (number) current value
@param leadingZero (boolean) true to use a zero, false for a space.
@return (string) number with at least two digits */
_formatNumber: function(value) {
return (value < 10 ? '0' : '') + value;
_formatNumber: function(value, leadingZero) {
var prefix = '0'
if(leadingZero === false) prefix = ' '
return (value < 10 ? prefix : '') + value;
},

/* Update the input field and notify listeners.
Expand Down