Skip to content

Commit

Permalink
fix: timezone offsets in 1904 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-schroeder committed Jun 26, 2024
1 parent 420ff88 commit eb315dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/format.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { date } from "./date"
import { parts } from "./parts"
import { fill, getOffsetFormat } from "./common"
import type { DateInput, Format, FormatOptions, FormatStyle, Part } from "./types"
import type {
DateInput,
Format,
FormatOptions,
FormatStyle,
Part,
} from "./types"
import { offset } from "./offset"
import { removeOffset } from "./removeOffset"
import { deviceLocale } from "./deviceLocale"
Expand Down
6 changes: 4 additions & 2 deletions src/offset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ export function offset(
utcTime: DateInput,
tzA = "UTC",
tzB = "device",
timeZoneToken: TimezoneToken = "Z" ,
timeZoneToken: TimezoneToken = "Z"
): string {
tzB = tzB === "device" ? deviceTZ() ?? "utc" : tzB
const d = date(utcTime)
const timeA = relativeTime(d, tzA)
const timeB = relativeTime(d, tzB)
const timeDiffInMins = (timeB.getTime() - timeA.getTime()) / 1000 / 60
const timeDiffInMins = Math.round(
(timeB.getTime() - timeA.getTime()) / 1000 / 60
)
return minsToOffset(timeDiffInMins, timeZoneToken)
}

0 comments on commit eb315dc

Please sign in to comment.