Skip to content

Commit 0691b20

Browse files
committed
pipleline-visualiser: change displayed times to users's locale if JS is available
A progressive enhancement. Otherwise the user will see the times as server times (Europe/London).
1 parent 16e4d19 commit 0691b20

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

support/pipeline-visualiser/views/group.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<% if pipeline.is_running? %>
3535
<%= pipeline.running_duration.human_str %> ago
3636
<% else %>
37-
<%= pipeline.last_started_at.strftime("%H:%M, %A %d %b %Y ") %>
37+
<%= erb :'partials/time', :locals => {time: pipeline.last_started_at } %>
3838
<% end %>
3939
</time>
4040
</td>

support/pipeline-visualiser/views/layout.erb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
background-color: #F2F3F3;
1919
padding: 2px 5px;
2020
}
21-
22-
time {
23-
text-decoration: underline;
24-
text-decoration-style: dashed;
25-
text-underline-offset: 8px;
26-
}
2721
</style>
2822
</head>
2923

@@ -121,6 +115,16 @@
121115
} from '/javascript/govuk-frontend-5.8.0.min.js'
122116
initAll()
123117
</script>
118+
119+
<script type="module">
120+
document.querySelectorAll("time").forEach((time) => {
121+
if(time.dateTime != null) {
122+
let globalTime = new Date(time.dateTime);
123+
let localTime = globalTime.toLocaleString();
124+
time.innerText = localTime;
125+
}
126+
});
127+
</script>
124128
</body>
125129

126130
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<time datetime="<%= time.strftime('%Y-%m-%dT%H:%M:%S.%L%z')%>"><%= time.strftime("%H:%M, %A %d %b %Y ") %></time>

support/pipeline-visualiser/views/pipeline.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</h1>
1212

1313
<p class="govuk-body">
14-
<strong>Last execution time</strong> <%= pipeline.last_started_at.strftime("%H:%M, %A %d %b %Y ") %>
14+
<strong>Last execution time</strong> <%= erb :'partials/time', :locals => {time: pipeline.last_started_at } %>
1515
</p>
1616
<p class="govuk-body">
1717
<strong>Execution id</strong> <%= pipeline.execution_id %>

0 commit comments

Comments
 (0)