Skip to content

Commit 64f7d6a

Browse files
committed
fix(site): correctly interpret timezone based on offset in formatOffset
1 parent df4f34a commit 64f7d6a

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 the 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)