Fix bug where 12:NN PM was being displaed as 0:NN PM

Change-Id: I941a8146fba3c85610e99bd70cd7a766d59700f2
This commit is contained in:
Andrew Bonventre
2016-01-27 12:59:10 -05:00
parent 12d6212986
commit 3f33f6735e
2 changed files with 9 additions and 2 deletions

View File

@@ -66,8 +66,12 @@ limitations under the License.
// Within 24 hours and on the same day:
// '2:14 AM'
var pm = t.getHours() >= 12;
var hours = t.getHours() === 0 ? 12 :
pm ? t.getHours() - 12 : t.getHours();
var hours = t.getHours();
if (hours == 0) {
hours = 12;
} else if (hours > 12) {
hours = t.getHours() - 12;
}
var minutes = t.getMinutes() < 10 ? '0' + t.getMinutes() :
t.getMinutes();
return hours + ':' + minutes + (pm ? ' PM' : ' AM');

View File

@@ -61,6 +61,9 @@ limitations under the License.
testDates('2015-07-29T20:34:00.000Z',
'2015-07-29T15:34:00.000Z',
'3:34 PM');
testDates('2016-01-27T17:41:00.000Z',
'2016-01-27T12:41:00.000Z',
'12:41 PM');
// Within 24 hours on different days.
testDates('2015-07-29T03:34:00.000Z',