Skip to content

Commit 6b3f599

Browse files
authored
fix(site): correctly interpret timezone based on offset in formatOffset (#10797)
Fixes #10784
1 parent 9b6433e commit 6b3f599

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -791,14 +791,14 @@ function toISOLocal(d: Date, offset: number) {
791791
}
792792

793793
function formatOffset(offset: number): string {
794-
const isPositive = offset >= 0;
794+
// A negative offset means that this is a positive timezone, e.g. GMT+2 = -120.
795+
const isPositiveTimezone = offset <= 0;
795796
const absoluteOffset = Math.abs(offset);
796797
const hours = Math.floor(absoluteOffset / 60);
797798
const minutes = Math.abs(offset) % 60;
798-
const formattedHours = `${isPositive ? "+" : "-"}${String(hours).padStart(
799-
2,
800-
"0",
801-
)}`;
799+
const formattedHours = `${isPositiveTimezone ? "+" : "-"}${String(
800+
hours,
801+
).padStart(2, "0")}`;
802802
const formattedMinutes = String(minutes).padStart(2, "0");
803803
return `${formattedHours}:${formattedMinutes}`;
804804
}

0 commit comments

Comments
 (0)