Skip to content

Commit

Permalink
chore: ts notation in offset
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-schroeder committed Mar 7, 2024
1 parent 0245e40 commit f90c217
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
17 changes: 17 additions & 0 deletions docs/assets/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions docs/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/deviceTZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
* * Note: If the environment variable TZ is not set, it will return undefined.
*/
export function deviceTZ(): string | undefined {
return Intl.DateTimeFormat().resolvedOptions().timeZone
return Intl.DateTimeFormat().resolvedOptions().timeZone as string | undefined
}
2 changes: 1 addition & 1 deletion src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function format(
genitive: boolean | undefined = false,
partFilter?: (part: Part) => boolean
): string {
let tz, forceOffset
let tz: string | undefined, forceOffset: string | undefined

if (
typeof inputDateOrOptions === "object" &&
Expand Down
2 changes: 1 addition & 1 deletion src/offset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function offset(
tzA = "UTC",
tzB = "device"
): string {
tzB = tzB === "device" ? deviceTZ() : tzB
tzB = tzB === "device" ? deviceTZ() ?? "utc" : tzB
const d = date(utcTime)
const timeA = relativeTime(d, tzA)
const timeB = relativeTime(d, tzB)
Expand Down

0 comments on commit f90c217

Please sign in to comment.