mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
fix(site): correctly interpret timezone based on offset in formatOffset
(#10797)
Fixes #10784
This commit is contained in:
committed by
GitHub
parent
9b6433e3a7
commit
6b3f599438
@ -791,14 +791,14 @@ function toISOLocal(d: Date, offset: number) {
|
||||
}
|
||||
|
||||
function formatOffset(offset: number): string {
|
||||
const isPositive = offset >= 0;
|
||||
// A negative offset means that this is a positive timezone, e.g. GMT+2 = -120.
|
||||
const isPositiveTimezone = offset <= 0;
|
||||
const absoluteOffset = Math.abs(offset);
|
||||
const hours = Math.floor(absoluteOffset / 60);
|
||||
const minutes = Math.abs(offset) % 60;
|
||||
const formattedHours = `${isPositive ? "+" : "-"}${String(hours).padStart(
|
||||
2,
|
||||
"0",
|
||||
)}`;
|
||||
const formattedHours = `${isPositiveTimezone ? "+" : "-"}${String(
|
||||
hours,
|
||||
).padStart(2, "0")}`;
|
||||
const formattedMinutes = String(minutes).padStart(2, "0");
|
||||
return `${formattedHours}:${formattedMinutes}`;
|
||||
}
|
||||
|
Reference in New Issue
Block a user