Skip to content

Commit 979bb04

Browse files
authored
Merge pull request #155 from ISISComputingGroup/fixed_timezone
Always use Europe/London timezone
2 parents eaa3999 + 49219e6 commit 979bb04

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

app/components/Block.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ it("renders block with timestamp and shows timestamp value", () => {
171171
expect(
172172
container.querySelector(`#${aBlock.human_readable_name}_TIMESTAMP`)!
173173
.innerHTML,
174-
).toContain(new Date(expectedTimeStamp * 1000).toLocaleString());
174+
).toContain("11 Nov 2024, 16:20:22");
175175
});
176176

177177
it("renders block without SP and hides SP value", () => {

app/components/Block.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import { useState } from "react";
55
const grafana_stub =
66
"https://shadow.nd.rl.ac.uk/grafana/d/wMlwwaHMk/block-history?viewPanel=2&orgId=1&var-block=";
77

8+
const date_format = new Intl.DateTimeFormat("en-GB", {
9+
dateStyle: "medium",
10+
timeStyle: "medium",
11+
timeZone: "Europe/London",
12+
});
13+
814
export default function Block({
915
pv,
1016
instName,
@@ -105,7 +111,7 @@ export default function Block({
105111
pv.updateSeconds > minimum_date_to_be_shown ? (
106112
<span id={pv.human_readable_name + "_TIMESTAMP"}>
107113
{/*Multiply by 1000 here as Date() expects milliseconds*/}
108-
{`Last update: ${new Date(pv.updateSeconds * 1000).toLocaleString()}`}
114+
{`Last update: ${date_format.format(pv.updateSeconds * 1000)}`}
109115
</span>
110116
) : null}
111117
</div>

0 commit comments

Comments
 (0)