Fix timezone

This commit is contained in:
Hanzei 2018-07-18 17:40:58 +02:00
parent b7f6532d04
commit ebd3b152f4
No known key found for this signature in database
GPG key ID: 69A2DEFD98937BA0
3 changed files with 9 additions and 12 deletions

View file

@ -22,10 +22,3 @@ $(document).keypress(function(e) {
$('.modal.is-active').removeClass('is-active');
}
});
{{ if and .Site.Params.localTime .Page.IsHome }}
$(document).ready(function() {
var time = moment().tz("{{ .Site.Params.timeZone }}").format("h:mm A");
$('#time').html(time);
})
{{ end }}

4
assets/js/initMoment.js Normal file
View file

@ -0,0 +1,4 @@
$(document).ready(function() {
var time = moment().tz("{{ .Site.Params.timeZone }}").format("h:mm A");
$('#time').html(time);
})

View file

@ -1,14 +1,14 @@
{{ $jQuery := resources.Get "vendor/jquery/jquery-3.3.1.min.js" }}
{{ $index := resources.Get "js/index.js" | resources.ExecuteAsTemplate "js/index.tmp.css" . | minify }}
{{ $index := resources.Get "js/index.js" | minify }}
{{ $scripts := slice $jQuery $index | resources.Concat "/js/bundle.js" | fingerprint }}
<script src="{{ $scripts.Permalink }}" integrity="{{ $scripts.Data.Integrity }}"></script>
{{ if and .Site.Params.localTime .Page.IsHome }}
{{ $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" }}
{{ $scripts := slice $jQuery $momentjs $momentTimezone $momentTimezoneWithData $index | resources.Concat "/js/bundleMoment.js" | fingerprint }}
<script src="{{ $scripts.Permalink }}" integrity="{{ $scripts.Data.Integrity }}"></script>
{{ else }}
{{ $scripts := slice $jQuery $index | resources.Concat "/js/bundle.js" | fingerprint }}
{{ $initMomentjs := resources.Get "js/initMoment.js" | resources.ExecuteAsTemplate "js/initMoment.tmp.js" . }}
{{ $scripts := slice $momentjs $momentTimezone $momentTimezoneWithData $initMomentjs | resources.Concat "/js/bundleMoment.js" | fingerprint }}
<script src="{{ $scripts.Permalink }}" integrity="{{ $scripts.Data.Integrity }}"></script>
{{ end }}