Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Fixed Am/Pm labels when given default value #50

Open
wants to merge 2 commits 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
19 changes: 17 additions & 2 deletions src/clockpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@
$('<button type="button" class="btn btn-sm btn-default clockpicker-button am-button">' + "AM" + '</button>')
.on("click", function() {
self.amOrPm = "AM";
$('.clockpicker-span-am-pm').empty().append('AM');
self.spanAmPm.empty().append(self.amOrPm);
}).appendTo(this.amPmBlock);


$('<button type="button" class="btn btn-sm btn-default clockpicker-button pm-button">' + "PM" + '</button>')
.on("click", function() {
self.amOrPm = 'PM';
$('.clockpicker-span-am-pm').empty().append('PM');
self.spanAmPm.empty().append(self.amOrPm);
}).appendTo(this.amPmBlock);

}
Expand Down Expand Up @@ -467,6 +467,21 @@
this.spanHours.html(leadingZero(this.hours));
this.spanMinutes.html(leadingZero(this.minutes));

if (this.options.twelvehour) {
if (this.hours == 12) {
this.amOrPm = 'PM';
}
else if (this.hours > 12) {
this.amOrPm = 'PM';
this.hours -= 12;
}
else {
this.amOrPm = 'AM';
}

this.spanAmPm.text(this.amOrPm);
}

// Toggle to hours view
this.toggleView('hours');

Expand Down