From f8b942e94dc224058a8c8b36094c9b37daa5311e Mon Sep 17 00:00:00 2001 From: taiebot Date: Sat, 21 Mar 2026 21:01:31 +0100 Subject: [PATCH 01/14] Create a service for offset calculation Signed-off-by: taiebot --- src/services/timezoneOffsetService.js | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/services/timezoneOffsetService.js diff --git a/src/services/timezoneOffsetService.js b/src/services/timezoneOffsetService.js new file mode 100644 index 0000000000..5ec0965292 --- /dev/null +++ b/src/services/timezoneOffsetService.js @@ -0,0 +1,44 @@ +/** + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +export function getTimezoneOffset(proposalDate: string, timezoneId: string): number { + let timezoneOffset = 0 + + try { + const date = new Date(proposalDate) + + const dtf = new Intl.DateTimeFormat('en-US', { + timeZone: timezoneId, + hour12: false, + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + }) + + const parts = dtf.formatToParts(date) + + const values: Record = {} + parts.forEach(({ type, value }) => { + if (type !== 'literal') values[type] = value + }) + + const asUTC = Date.UTC( + Number(values.year), + Number(values.month) - 1, + Number(values.day), + Number(values.hour), + Number(values.minute), + Number(values.second) + ) + + timezoneOffset = Math.round((asUTC - date.getTime()) / 60000) + } catch (e) { + timezoneOffset = 0 + } + + return timezoneOffset +} \ No newline at end of file From 43b2e238c8090188bb0d01b7458b38f4cbcfaaf5 Mon Sep 17 00:00:00 2001 From: taiebot Date: Sat, 21 Mar 2026 21:12:21 +0100 Subject: [PATCH 02/14] Refactor timezone offset calculation in ProposalDateItem Replaced manual timezone offset calculation with a call to getTimezoneOffset function. Signed-off-by: taiebot --- src/components/Proposal/ProposalDateItem.vue | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/components/Proposal/ProposalDateItem.vue b/src/components/Proposal/ProposalDateItem.vue index 1a25165d82..550e03db1c 100644 --- a/src/components/Proposal/ProposalDateItem.vue +++ b/src/components/Proposal/ProposalDateItem.vue @@ -1,5 +1,5 @@ @@ -21,6 +21,7 @@