From 93036995c4fd5c029db50d5c3a7b13777b020342 Mon Sep 17 00:00:00 2001 From: Solomon Cammack Date: Wed, 16 Oct 2024 08:21:51 +0100 Subject: [PATCH] Avoid timezone errors where spacetime calculates the wrong epoch --- pnpm-lock.yaml | 10 +++++----- website/package.json | 2 +- website/src/utils/content-utils.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 345176e2..ac7113fe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -154,8 +154,8 @@ importers: specifier: ^4.0.1 version: 4.7.5 spacetime: - specifier: ^7.4.1 - version: 7.6.0 + specifier: ^7.6.2 + version: 7.6.2 spacetime-informal: specifier: ^0.6.1 version: 0.6.1 @@ -2651,8 +2651,8 @@ packages: spacetime-informal@0.6.1: resolution: {integrity: sha512-fOA+RMi2mpCbkLkjBIzWQttmkYE/v9VfdbbrvE2Pus/WoiQNmHO20YGNEqJOuFADsrrZOd/hJVuBwAkV3s6BHg==} - spacetime@7.6.0: - resolution: {integrity: sha512-pQ1K7XNmmcFGRtF2LzXkfgQ02+NbV6W9v+0UmxnPe0xVByqFDbKkKI1uangS+9ZG5Ey2HeFh74EL9rKE7V/k9A==} + spacetime@7.6.2: + resolution: {integrity: sha512-x5Qr2yiG5wy/0IBeaNeYG9OLigePKTj1/liF9j5xWNbb1psi5Q2AuZTh9SpIT+QZqpKCWX0OCdvwJIm9FlJouA==} spdx-correct@3.2.0: resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==} @@ -5625,7 +5625,7 @@ snapshots: dependencies: efrt-unpack: 2.2.0 - spacetime@7.6.0: {} + spacetime@7.6.2: {} spdx-correct@3.2.0: dependencies: diff --git a/website/package.json b/website/package.json index e356ac5b..c75105dc 100644 --- a/website/package.json +++ b/website/package.json @@ -29,7 +29,7 @@ "pinia": "^2.1.7", "pinia-plugin-persistedstate": "^3.2.1", "socket.io-client": "^4.0.1", - "spacetime": "^7.4.1", + "spacetime": "^7.6.2", "spacetime-informal": "^0.6.1", "timesync": "^1.0.11", "typescript": "^5.4.5", diff --git a/website/src/utils/content-utils.js b/website/src/utils/content-utils.js index a4026686..10ae72c5 100644 --- a/website/src/utils/content-utils.js +++ b/website/src/utils/content-utils.js @@ -403,14 +403,14 @@ function getNoSunAbbreviation(abbrev) { * * @param {ParsableDate | Date | number | Array | string} timeString - spacetime parsable date/time string * @param {string?} tz - site timezone from store - * @param {string?} format - override for format + * @param {string} format - override for format * @param {boolean?} use24HourTime - use 24 hour time * @returns {string} */ export function formatTime(timeString, { tz, use24HourTime = false, format = "{day-short} {date-ordinal} {month-short} {year} {time} {tz}" } = {}) { if (!tz) tz = useSettingsStore().timezone; const timezone = getTimezone(tz); - const time = spacetime(timeString).goto(timezone); + const time = spacetime((new Date(timeString)).getTime()).goto(timezone); const abbrev = getAbbrev(timezone, time); return time.format( format