mirror of
https://github.com/benbusby/farside.git
synced 2025-04-19 06:45:55 -04:00
last updated shows in local time
This commit is contained in:
parent
ad2da6cdc6
commit
dfad1393b2
23
index.eex
23
index.eex
@ -35,7 +35,7 @@
|
||||
<div id="child-div">
|
||||
<h1>Farside [<a href="https://sr.ht/~benbusby/farside">SourceHut</a>, <a href="https://github.com/benbusby/farside">GitHub</a>]</h1>
|
||||
<hr>
|
||||
<h3>Last synced <%= DateTime.truncate(last_updated, :second) %> UTC</h2>
|
||||
<h3>Last synced <span id="last_updated"><%= DateTime.truncate(last_updated, :second) %></span></h2>
|
||||
<div>
|
||||
<ul>
|
||||
<%= for service <- services do %>
|
||||
@ -50,4 +50,25 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var client_timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||
|
||||
var options = {
|
||||
timeZone: client_timezone,
|
||||
year: 'numeric', month: 'numeric', day: 'numeric',
|
||||
hour: 'numeric', minute: 'numeric', second: 'numeric'
|
||||
};
|
||||
|
||||
var formatter = new Intl.DateTimeFormat([], options);
|
||||
|
||||
var time = "<%= DateTime.truncate(last_updated, :second) %>";
|
||||
|
||||
var element_to_write = document.getElementById("last_updated");
|
||||
|
||||
var localized_time = formatter.format(new Date(time));
|
||||
|
||||
element_to_write.innerHTML = localized_time;
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user