From 96664ab922202f65ed98e0067752e9365027d8e4 Mon Sep 17 00:00:00 2001 From: Kirk Waiblinger <53019676+kirkwaiblinger@users.noreply.github.com> Date: Mon, 4 Aug 2025 14:47:27 -0600 Subject: [PATCH 1/2] docs: fix time zone and DST mistakes in release date --- docs/users/Releases.mdx | 43 +++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/docs/users/Releases.mdx b/docs/users/Releases.mdx index 81c6b504dddc..65305967e672 100644 --- a/docs/users/Releases.mdx +++ b/docs/users/Releases.mdx @@ -8,13 +8,44 @@ import useIsBrowser from '@docusaurus/useIsBrowser'; export function LocalTimeOfRelease() { const isBrowser = useIsBrowser(); - // An arbitrary Monday at 17:00 UTC. - const date = new Date('1970-01-05T17:00Z'); - const formatted = date.toLocaleTimeString('en-US', { + if (!isBrowser) { + // An arbitrary Monday at 17:00 UTC. + const arbitraryMonday = new Date('1970-01-05T17:00Z'); + return arbitraryMonday.toLocaleTimeString('en-US', { + hour: 'numeric', + minute: '2-digit', + timeZoneName: 'short', + timeZone: 'UTC', + }); + } + const now = new Date(); + const daysAgoToMonday = (now.getUTCDay() + 6) % 7; + // Calculate the previous Monday at 17:00 UTC. + const previousReleaseDate = new Date( + Date.UTC( + now.getUTCFullYear(), + now.getUTCMonth(), + now.getUTCDate() - daysAgoToMonday, + 17, + ), + ); + // This will happen if the current time is before 17:00 UTC on Monday. + if (previousReleaseDate > now) { + previousReleaseDate.setUTCDate(previousReleaseDate.getUTCDate() - 7); + } + // Next release is 7 days later. + const nextReleaseDate = new Date(previousReleaseDate.getTime()); + nextReleaseDate.setUTCDate(previousReleaseDate.getUTCDate() + 7); + // If we're near a DST time change, we want to display the time of the release that has the same UTC offset as now. + // If, for some reason, neither does, just display the local time of the next release. + const dateWithSameUtcOffset = + [nextReleaseDate, previousReleaseDate].find( + date => date.getTimezoneOffset() === now.getTimezoneOffset(), + ) ?? nextReleaseDate; + const formatted = dateWithSameUtcOffset.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', timeZoneName: 'short', - timeZone: isBrowser ? undefined : 'UTC', }); // Specify the day of week if it's not a Monday. const dayNames = [ @@ -26,8 +57,8 @@ export function LocalTimeOfRelease() { 'Friday', 'Saturday', ]; - if (date.getDay() !== date.getUTCDay()) { - return `${dayNames[date.getDay()]}s at ${formatted}`; + if (dateWithSameUtcOffset.getDay() !== dateWithSameUtcOffset.getUTCDay()) { + return `${dayNames[dateWithSameUtcOffset.getDay()]}s at ${formatted}`; } return formatted; } From 12c26bbc1058d3bcd17be70057ea9bb509a84a1e Mon Sep 17 00:00:00 2001 From: Kirk Waiblinger <53019676+kirkwaiblinger@users.noreply.github.com> Date: Mon, 4 Aug 2025 15:00:08 -0600 Subject: [PATCH 2/2] rename var --- docs/users/Releases.mdx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/users/Releases.mdx b/docs/users/Releases.mdx index 65305967e672..58a4e5c6175d 100644 --- a/docs/users/Releases.mdx +++ b/docs/users/Releases.mdx @@ -38,11 +38,11 @@ export function LocalTimeOfRelease() { nextReleaseDate.setUTCDate(previousReleaseDate.getUTCDate() + 7); // If we're near a DST time change, we want to display the time of the release that has the same UTC offset as now. // If, for some reason, neither does, just display the local time of the next release. - const dateWithSameUtcOffset = + const releaseWithSameUtcOffset = [nextReleaseDate, previousReleaseDate].find( date => date.getTimezoneOffset() === now.getTimezoneOffset(), ) ?? nextReleaseDate; - const formatted = dateWithSameUtcOffset.toLocaleTimeString('en-US', { + const formatted = releaseWithSameUtcOffset.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', timeZoneName: 'short', @@ -57,8 +57,10 @@ export function LocalTimeOfRelease() { 'Friday', 'Saturday', ]; - if (dateWithSameUtcOffset.getDay() !== dateWithSameUtcOffset.getUTCDay()) { - return `${dayNames[dateWithSameUtcOffset.getDay()]}s at ${formatted}`; + if ( + releaseWithSameUtcOffset.getDay() !== releaseWithSameUtcOffset.getUTCDay() + ) { + return `${dayNames[releaseWithSameUtcOffset.getDay()]}s at ${formatted}`; } return formatted; }