From 1152cf482d7bb57b7d1ba56dc95960e0b04f40bc Mon Sep 17 00:00:00 2001 From: twig Date: Thu, 7 May 2015 17:35:59 +1000 Subject: [PATCH 1/2] Fixed Am/Pm labels when given default value Default value of "13:14" (as given in example README) will display "1:14 PM" on the clock picker when displayed. --- src/clockpicker.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/clockpicker.js b/src/clockpicker.js index 7f208aa..861ef7f 100644 --- a/src/clockpicker.js +++ b/src/clockpicker.js @@ -147,14 +147,14 @@ $('') .on("click", function() { self.amOrPm = "AM"; - $('.clockpicker-span-am-pm').empty().append('AM'); + self.spanAmPm.empty().append(self.amOrPm); }).appendTo(this.amPmBlock); $('') .on("click", function() { self.amOrPm = 'PM'; - $('.clockpicker-span-am-pm').empty().append('PM'); + self.spanAmPm.empty().append(self.amOrPm); }).appendTo(this.amPmBlock); } @@ -467,6 +467,18 @@ this.spanHours.html(leadingZero(this.hours)); this.spanMinutes.html(leadingZero(this.minutes)); + if (this.options.twelvehour) { + 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'); From 3b208d98917e8bb0e17c6cb52bb670b0cecdd2c8 Mon Sep 17 00:00:00 2001 From: twig Date: Fri, 8 May 2015 12:09:52 +1000 Subject: [PATCH 2/2] Update clockpicker.js Fixed up some logic issues with 12pm --- src/clockpicker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/clockpicker.js b/src/clockpicker.js index 861ef7f..ffd3428 100644 --- a/src/clockpicker.js +++ b/src/clockpicker.js @@ -468,7 +468,10 @@ this.spanMinutes.html(leadingZero(this.minutes)); if (this.options.twelvehour) { - if (this.hours > 12) { + if (this.hours == 12) { + this.amOrPm = 'PM'; + } + else if (this.hours > 12) { this.amOrPm = 'PM'; this.hours -= 12; }