diff options
author | Jacques Supcik <jacques@supcik.net> | 2019-09-01 00:52:30 +0300 |
---|---|---|
committer | Ben Schumacher <hanzei@mailbox.org> | 2019-09-01 00:52:30 +0300 |
commit | 5205eeac73cd2d4482dbcf6677a7cd636c62e8b3 (patch) | |
tree | d0eac182a6c5c1225b408a72e45d6afc6a1a8e7b /assets | |
parent | 8b1684b6c27c51bde5c4bb058e40e288089eb129 (diff) |
Add `timeRefresh` for periodic localtime update and allow for multilingual time format (#177)
Diffstat (limited to 'assets')
-rw-r--r-- | assets/js/initMoment.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/assets/js/initMoment.js b/assets/js/initMoment.js index e638cf1..9b7cb33 100644 --- a/assets/js/initMoment.js +++ b/assets/js/initMoment.js @@ -1,4 +1,11 @@ $(document).ready(function() { - var time = moment().tz("{{ .Site.Params.home.timeZone }}").format("{{ .Site.Params.home.timeFormat }}"); - $("#time").html(time); + const tnode = $("#time") + const update_localtime = function(){ + var time = moment() + .tz(tnode.attr("data-time-zone")) + .format(tnode.attr("data-time-format")); + tnode.html(time); + } + update_localtime(); + setInterval(update_localtime, 1000); }) |