From 93de138ff3e0449f1935a5c40d65380ae7473de7 Mon Sep 17 00:00:00 2001 From: Bao Trinh Date: Thu, 5 Dec 2024 03:49:08 -0600 Subject: [PATCH] feat(dates): allow configurable default timezone --- docs/configuration.md | 1 + quartz/build.ts | 1 + quartz/cfg.ts | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 1622da6fa414a..dfa0b5bb57651 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -35,6 +35,7 @@ This part of the configuration concerns anything that can affect the whole site. - `{ provider: 'cabin' }` or `{ provider: 'cabin', host: 'https://cabin.example.com' }` (custom domain): use [Cabin](https://withcabin.com); - `{provider: 'clarity', projectId: ' void) { LuxonSettings.throwOnInvalid = true LuxonSettings.defaultLocale = cfg.configuration.locale + if (cfg.configuration.timezone) LuxonSettings.defaultZone = cfg.configuration.timezone const pluginCount = Object.values(cfg.plugins).flat().length const pluginNames = (key: "transformers" | "filters" | "emitters") => diff --git a/quartz/cfg.ts b/quartz/cfg.ts index 135f584994a6d..3aaa4999e378c 100644 --- a/quartz/cfg.ts +++ b/quartz/cfg.ts @@ -75,6 +75,12 @@ export interface GlobalConfiguration { * Region Codes: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 */ locale: ValidLocale + /** + * The default timezone when handling dates. + * Valid options are "system" (default), "utc", an IANA string, or a UTC offset + * https://moment.github.io/luxon/#/zones?id=specifying-a-zone + */ + timezone?: "system" | string } export interface QuartzConfig {