added 12h option

This commit is contained in:
Jiiks 2016-06-27 20:09:48 +03:00
parent 284838bb5c
commit 9a97a5cc2e
1 changed files with 22 additions and 0 deletions

View File

@ -23,6 +23,28 @@ clockPlugin.prototype.start = function () {
var current_time = [h,m,s].join(':');
self.clock.html(current_time);
};
this.ticktock12 = function() {
var suffix = "AM";
var d = new Date();
var h = d.getHours();
var m = self.pad(d.getMinutes());
var s = self.pad(d.getSeconds());
if(h >= 12) {
h -= 12;
suffix = "PM";
}
if(h == 0) {
h = 12;
}
h = self.pad(h);
var current_time = [h,m,s].join(":") + suffix;
self.clock.html(current_time);
};
this.ticktock();
this.interval = setInterval(this.ticktock, 1000);
};