diff options
author | MyGiHu <74786828+MyGiHu@users.noreply.github.com> | 2020-12-04 18:49:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-04 18:49:32 +0300 |
commit | 6925c0248cf70674576d42d173ff33b00a3d522a (patch) | |
tree | e3aaa7f60c15f717e7cce2eda7258c682cae22a2 /layouts/index.html | |
parent | 293ab665ca52f3c7d8d3273ca79fa7949493b1ea (diff) |
Replacing Moment.js with native JavaScript (#266)
* fix-262
* Replacing Moment.js with native JavaScript
Diffstat (limited to 'layouts/index.html')
-rw-r--r-- | layouts/index.html | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/layouts/index.html b/layouts/index.html index fd1787c..d9243c3 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -106,7 +106,7 @@ {{ .Content }} </div> {{ if .Site.Params.home.localTime }} - <p>{{ i18n "index_currentTime" . }} <span id="time" data-time-zone="{{ .Site.Params.home.timeZone }}" data-time-format="{{ .Site.Params.home.timeFormat }}"></span>.</p> + <p>{{ i18n "index_currentTime" . }} <span id="time"></span>.</p> {{ end }} {{ with .Site.Params.email }} <h3 class="subtitle is-3 has-text-centered top-pad"> @@ -132,12 +132,15 @@ {{ partial "js/owlCarousel.html" . }} {{ if .Site.Params.home.localTime }} - {{ $momentjs := resources.Get "vendor/momentjs/moment.min.js" }} - {{ $momentTimezone := resources.Get "vendor/momentjs/moment-timezone.min.js" }} - {{ $momentTimezoneWithData := resources.Get "vendor/momentjs/moment-timezone-with-data-2012-2022.min.js" }} - {{ $initMomentjs := resources.Get "js/initMoment.js" }} - {{ $bundleMoment := slice $momentjs $momentTimezone $momentTimezoneWithData $initMomentjs | resources.Concat "js/bundleMoment.js" | fingerprint }} - <script src="{{ $bundleMoment.Permalink }}" integrity="{{ $bundleMoment.Data.Integrity }}"></script> + <script> + function update_localtime() { + const time = new Date().toLocaleTimeString('{{ .Site.Params.home.timeFormat }}', { timeZone: '{{ .Site.Params.home.timeZone }}', timeStyle: 'short' }); + document.getElementById('time').innerHTML = time; + } + update_localtime(); + // Updating every second to prevent seconds looking like stood still when timeStyle is ignored. + setInterval(update_localtime, 1000); + </script> {{ end }} </body> |