diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 7a93bb66a8..4c5e18a5e9 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -37,7 +37,11 @@ jobs: - run: make deps-frontend - run: make lint-frontend - run: make checks-frontend - - run: make test-frontend-coverage + - run: | + # Usage of `dayjs` can be impacted by local system timezone and can be sensitive to DST differences; since + # frontend tests are very short they're run twice with varying DST rules to reduce regression risk. + TZ=Europe/Berlin make test-frontend-coverage + TZ=America/Edmonton make test-frontend-coverage - run: make frontend - name: Install zstd for cache saving # works around https://github.com/actions/cache/issues/1169, because the diff --git a/web_src/js/webcomponents/relative-time.js b/web_src/js/webcomponents/relative-time.js index 2ec87450c1..c070cd6795 100644 --- a/web_src/js/webcomponents/relative-time.js +++ b/web_src/js/webcomponents/relative-time.js @@ -1,6 +1,9 @@ import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc.js'; const {pageData} = window.config; +dayjs.extend(utc); + export const HALF_MINUTE = 30 * 1000; export const ONE_MINUTE = 60 * 1000; export const ONE_HOUR = 60 * ONE_MINUTE; @@ -103,8 +106,8 @@ export function DoUpdateRelativeTime(object, now) { if (!now) now = Date.now(); - const nowJS = dayjs(now); - const thenJS = dayjs(absoluteTime); + const nowJS = dayjs.utc(now); + const thenJS = dayjs.utc(absoluteTime); object.setAttribute('data-tooltip-content', ABSOLUTE_DATETIME_FORMAT.format(thenJS.toDate()));