Skip to content

Commit

Permalink
[CI] Add timezone to build timestamp (open-telemetry#3113)
Browse files Browse the repository at this point in the history
Co-authored-by: Phillip Carter <pcarter@fastmail.com>
  • Loading branch information
2 people authored and svrnm committed Aug 1, 2023
1 parent 7a76e6c commit e2c20f7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion layouts/shortcodes/site-build-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{{ $isNetlifyBuilt := os.Getenv "NETLIFY" | default false -}}
{{ $isPR := os.Getenv "PULL_REQUEST" -}}
{{ $reviewID := os.Getenv "REVIEW_ID" -}}
{{ $now := now -}}

Netlify build information:

Expand All @@ -17,7 +18,7 @@ Netlify built | `{{ $isNetlifyBuilt }}`

{{/* Don't show timestamp for local builds to avoid affecting site diffs. */ -}}
{{ with $isNetlifyBuilt -}}
Date/time[^date] | {{ now.Format "2006-01-02 15:04" }}
Date/time[^date] | {{ $now.Format "2006-01-02 15:04 MST" }}[^local-time]
{{ end -}}
{{/* */ -}}

Expand Down Expand Up @@ -55,3 +56,12 @@ Deploy context | {{ os.Getenv "CONTEXT" | default "local" }}
{{/* End of table */}}

[^date]: Approximate build timestamp.
[^local-time]: In your timezone: <span id="local-time">unknown</span>.

<script>
document.addEventListener("DOMContentLoaded", function() {
var options = { hour: '2-digit', hour12: false, minute: '2-digit', timeZoneName: 'short' };
var buildDate = new Date("{{ $now.Format "2006-01-02T15:04:05Z07:00" }}");
document.getElementById("local-time").innerText = buildDate.toLocaleString(undefined, options);
});
</script>

0 comments on commit e2c20f7

Please sign in to comment.