added 12h option
This commit is contained in:
parent
284838bb5c
commit
9a97a5cc2e
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue