summaryrefslogtreecommitdiff
path: root/tempo.js
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-02-23 14:52:33 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2014-02-23 14:52:33 -0800
commitcf9cdaade95defa2e78b5bd78105a072f028eefc (patch)
treeba06178c3aa5c4751a7454ae6d494c4f9b4d0717 /tempo.js
parent9b8ae10b8603815362f7bc483dc3ee78f488cf84 (diff)
downloadtempo-cf9cdaade95defa2e78b5bd78105a072f028eefc.tar.gz
tempo-cf9cdaade95defa2e78b5bd78105a072f028eefc.tar.xz
Implement a working date/time display.
Diffstat (limited to 'tempo.js')
-rw-r--r--tempo.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/tempo.js b/tempo.js
new file mode 100644
index 0000000..db8c039
--- /dev/null
+++ b/tempo.js
@@ -0,0 +1,35 @@
+var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+
+function padTime(x) {
+ if(x < 10) {
+ return "0" + x;
+ } else {
+ return x;
+ }
+}
+
+function updateTime() {
+ var date = new Date();
+
+ var h = date.getHours();
+ var m = date.getMinutes();
+ var s = date.getSeconds();
+
+ var dd = date.getDate();
+ var dm = date.getMonth();
+ var dy = date.getFullYear();
+
+ var str_t = padTime(h) + ":" + padTime(m) + ":" + padTime(s);
+ var str_d = dd + " " + months[dm] + " " + dy;
+
+ document.getElementById("timeval").innerHTML = str_t;
+ document.getElementById("dateval").innerHTML = str_d;
+}
+
+function startTempo() {
+ updateTime();
+
+ setInterval(updateTime, 1000);
+}
+
+window.onload = startTempo;