Skip to content

Commit fa6672f

Browse files
authored
feat(toolbox): add timezone and noop (#120)
1 parent ad6900b commit fa6672f

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

toolbox/noop.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** No operation. */
2+
export function noop(): void {}

toolbox/noop_test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { expect, test } from "@libs/testing"
2+
import { noop } from "./noop.ts"
3+
4+
test("`noop()` does nothing", () => expect(noop()).toBeUndefined())

toolbox/timezone.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** Supported timezones in the current runtime. */
2+
export const timezones = [...Intl.supportedValuesOf("timeZone"), "UTC"] as string[]
3+
4+
/** Current timezone in the runtime. */
5+
export const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone as string

toolbox/timezone_test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) - 2025+ the lowlighter/esquie authors. AGPL-3.0-or-later
2+
import { expect, test } from "@libs/testing"
3+
import { timezone, timezones } from "./timezone.ts"
4+
5+
test("`timezones` contains supported timezones", () => {
6+
expect(timezones.length).toBeGreaterThan(0)
7+
expect(timezones).toContain("Europe/Paris")
8+
expect(timezones).not.toContain("Invalid/Timezone")
9+
})
10+
11+
test("`timezone` is defined", () => {
12+
expect(timezone).toBeType("string")
13+
})

0 commit comments

Comments
 (0)