Skip to content

Commit

Permalink
Add more tests for #203
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen committed Sep 22, 2024
1 parent d5d27ae commit a012098
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Timezones.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe("Timezones", () => {
})
}
})

describe("accepts valid inputs", () => {
const ts = new Date("2023-01-01T01:00:00").getTime()
for (const ea of [
Expand Down Expand Up @@ -128,6 +129,7 @@ describe("Timezones", () => {
describe("extractTzOffsetFromTags", () => {
describe("with TimeZone", () => {
for (const { tzo, exp } of [
{ tzo: "+00:00", exp: "UTC" },
{ tzo: "-9", exp: "UTC-9" },
{ tzo: "-09:00", exp: "UTC-9" },
{ tzo: "+5:30", exp: "UTC+5:30" },
Expand Down
5 changes: 5 additions & 0 deletions src/Timezones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ export function normalizeZone(
if (input instanceof Zone) {
return isZoneValid(input) ? input : undefined
}

// This test and short-circuit may not be necessary, but it's cheap and
// explicit:
if (isUTC(input)) return FixedOffsetZone.utcInstance

let z = input
if (typeof z === "string") {
z = z.replace(/^(?:Zulu|Z|GMT)(?:\b|$)/, "UTC")
Expand Down

0 comments on commit a012098

Please sign in to comment.