Skip to content

Commit eb315dc

Browse files
fix: timezone offsets in 1904 (#59)
1 parent 420ff88 commit eb315dc

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/format.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { date } from "./date"
22
import { parts } from "./parts"
33
import { fill, getOffsetFormat } from "./common"
4-
import type { DateInput, Format, FormatOptions, FormatStyle, Part } from "./types"
4+
import type {
5+
DateInput,
6+
Format,
7+
FormatOptions,
8+
FormatStyle,
9+
Part,
10+
} from "./types"
511
import { offset } from "./offset"
612
import { removeOffset } from "./removeOffset"
713
import { deviceLocale } from "./deviceLocale"

src/offset.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ export function offset(
5050
utcTime: DateInput,
5151
tzA = "UTC",
5252
tzB = "device",
53-
timeZoneToken: TimezoneToken = "Z" ,
53+
timeZoneToken: TimezoneToken = "Z"
5454
): string {
5555
tzB = tzB === "device" ? deviceTZ() ?? "utc" : tzB
5656
const d = date(utcTime)
5757
const timeA = relativeTime(d, tzA)
5858
const timeB = relativeTime(d, tzB)
59-
const timeDiffInMins = (timeB.getTime() - timeA.getTime()) / 1000 / 60
59+
const timeDiffInMins = Math.round(
60+
(timeB.getTime() - timeA.getTime()) / 1000 / 60
61+
)
6062
return minsToOffset(timeDiffInMins, timeZoneToken)
6163
}

0 commit comments

Comments
 (0)