mirror of
https://github.com/Xevion/bus-reminder.git
synced 2025-12-17 10:11:20 -06:00
Correct details surrounding Intl.supportedValuesOf, improve comments/solve TODO
This commit is contained in:
3
src/env/schema.mjs
vendored
3
src/env/schema.mjs
vendored
@@ -1,8 +1,9 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
// @ts-ignore
|
// If this line fails, you're not running Node v18 or higher. Please upgrade.
|
||||||
const TimezoneSchema = z.enum(Intl.supportedValuesOf("timeZone"));
|
const TimezoneSchema = z.enum(Intl.supportedValuesOf("timeZone"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify your server-side environment variables schema here.
|
* Specify your server-side environment variables schema here.
|
||||||
* This way you can ensure the app isn't built with invalid env vars.
|
* This way you can ensure the app isn't built with invalid env vars.
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ import { utcToZonedTime } from 'date-fns-tz';
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { env } from '@/env/server.mjs';
|
import { env } from '@/env/server.mjs';
|
||||||
|
|
||||||
// @ts-ignore TS2339 -- TODO: Figure out why Intl.supportedValuesOf isn't seen by Typescript
|
// If this line fails in Typescript, then install typescript@^5.1.3
|
||||||
export const TimezoneSchema = z.enum(Intl.supportedValuesOf('timeZone'));
|
export const TimezoneSchema = z.enum(
|
||||||
|
// 'as' to assume at least one element
|
||||||
|
Intl.supportedValuesOf('timeZone') as [string, ...string[]]
|
||||||
|
);
|
||||||
export type Timezone = z.infer<typeof TimezoneSchema>;
|
export type Timezone = z.infer<typeof TimezoneSchema>;
|
||||||
|
|
||||||
export function localNow(now?: Date, zone?: Timezone): Date {
|
export function localNow(now?: Date, zone?: Timezone): Date {
|
||||||
|
|||||||
Reference in New Issue
Block a user