diff --git a/src/format.ts b/src/format.ts index c2a8ddf..7777b14 100644 --- a/src/format.ts +++ b/src/format.ts @@ -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" diff --git a/src/offset.ts b/src/offset.ts index 939d394..1f2f484 100644 --- a/src/offset.ts +++ b/src/offset.ts @@ -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) }