Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max hours more than 24 bugs #365

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
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
30 changes: 18 additions & 12 deletions js/bootstrap-timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@
templateContent;

if (this.showInputs) {
hourTemplate = '<input type="text" class="bootstrap-timepicker-hour" maxlength="2"/>';
var maxLength = '';
if (isFinite(this.maxHours)) {
maxLength = 'maxlength="'+this.maxHours.toString().length+'"';
}
hourTemplate = '<input type="text" class="bootstrap-timepicker-hour" '+maxLength+'/>';
minuteTemplate = '<input type="text" class="bootstrap-timepicker-minute" maxlength="2"/>';
secondTemplate = '<input type="text" class="bootstrap-timepicker-second" maxlength="2"/>';
meridianTemplate = '<input type="text" class="bootstrap-timepicker-meridian" maxlength="2"/>';
Expand Down Expand Up @@ -827,19 +831,21 @@
second = timeArray[2] ? timeArray[2].toString() : '';

// adaptive time parsing
if (hour.length > 4) {
second = hour.slice(-2);
hour = hour.slice(0, -2);
}
if (+hour > this.maxHours) {
if (hour.length > 4) {
second = hour.slice(-2);
hour = hour.slice(0, -2);
}

if (hour.length > 2) {
minute = hour.slice(-2);
hour = hour.slice(0, -2);
}
if (hour.length > 2) {
minute = hour.slice(-2);
hour = hour.slice(0, -2);
}

if (minute.length > 2) {
second = minute.slice(-2);
minute = minute.slice(0, -2);
if (minute.length > 2) {
second = minute.slice(-2);
minute = minute.slice(0, -2);
}
}

hour = parseInt(hour, 10);
Expand Down