Fix timezone display issues with formatted dates

Fixes #88

Also update Deno, hoping it might help with #87, but it's unlikely
This commit is contained in:
Bruno Bernardino
2025-08-21 17:09:32 +01:00
parent 8ff0a434fd
commit 4864c283b7
11 changed files with 68 additions and 14 deletions

2
.dvmrc
View File

@@ -1 +1 @@
2.4.2 2.4.4

View File

@@ -1,3 +1,4 @@
TZ="UTC" # optional, forces the server timezone to be UTC, which is the default, anyway
PORT=8000 PORT=8000
POSTGRESQL_HOST="postgresql" # docker container name or external hostname/IP POSTGRESQL_HOST="postgresql" # docker container name or external hostname/IP

View File

@@ -1,4 +1,4 @@
FROM denoland/deno:ubuntu-2.4.2 FROM denoland/deno:ubuntu-2.4.4
EXPOSE 8000 EXPOSE 8000

View File

@@ -13,10 +13,17 @@ export default function ListExpenses(
onClickEditExpense, onClickEditExpense,
}: ListExpensesProps, }: ListExpensesProps,
) { ) {
const dateFormat = new Intl.DateTimeFormat('en-US', { const dateFormatOptions: Intl.DateTimeFormatOptions = {
month: 'short', month: 'short',
day: 'numeric', day: 'numeric',
}); };
// Force timeZone to UTC for the server rendering
if (typeof window === 'undefined') {
dateFormatOptions.timeZone = 'UTC';
}
const dateFormat = new Intl.DateTimeFormat('en-US', dateFormatOptions);
return ( return (
<section class='mx-auto max-w-7xl my-8 mt-12'> <section class='mx-auto max-w-7xl my-8 mt-12'>

View File

@@ -63,7 +63,18 @@ export default function MainExpenses({ initialBudgets, initialExpenses, initialM
const shouldResetBudgetModal = useSignal<boolean>(false); const shouldResetBudgetModal = useSignal<boolean>(false);
const searchTimeout = useSignal<ReturnType<typeof setTimeout>>(0); const searchTimeout = useSignal<ReturnType<typeof setTimeout>>(0);
const dateFormat = new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: 'long' }); const dateFormatOptions: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'long',
};
// Force timeZone to UTC for the server rendering
if (typeof window === 'undefined') {
dateFormatOptions.timeZone = 'UTC';
}
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
const thisMonth = new Date().toISOString().substring(0, 7); const thisMonth = new Date().toISOString().substring(0, 7);
function onClickImportFile() { function onClickImportFile() {

View File

@@ -44,14 +44,21 @@ export default function ListFiles(
fileShareId, fileShareId,
}: ListFilesProps, }: ListFilesProps,
) { ) {
const dateFormat = new Intl.DateTimeFormat('en-GB', { const dateFormatOptions: Intl.DateTimeFormatOptions = {
year: 'numeric', year: 'numeric',
month: 'long', month: 'long',
day: 'numeric', day: 'numeric',
hour12: false, hour12: false,
hour: '2-digit', hour: '2-digit',
minute: '2-digit', minute: '2-digit',
}); };
// Force timeZone to UTC for the server rendering
if (typeof window === 'undefined') {
dateFormatOptions.timeZone = 'UTC';
}
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
let routePath = fileShareId ? `file-share/${fileShareId}` : 'files'; let routePath = fileShareId ? `file-share/${fileShareId}` : 'files';
let itemSingleLabel = 'file'; let itemSingleLabel = 'file';

View File

@@ -26,14 +26,21 @@ export default function ListFiles(
isShowingNotes, isShowingNotes,
}: ListFilesProps, }: ListFilesProps,
) { ) {
const dateFormat = new Intl.DateTimeFormat('en-GB', { const dateFormatOptions: Intl.DateTimeFormatOptions = {
year: 'numeric', year: 'numeric',
month: 'long', month: 'long',
day: 'numeric', day: 'numeric',
hour12: false, hour12: false,
hour: '2-digit', hour: '2-digit',
minute: '2-digit', minute: '2-digit',
}); };
// Force timeZone to UTC for the server rendering
if (typeof window === 'undefined') {
dateFormatOptions.timeZone = 'UTC';
}
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
const routePath = isShowingNotes ? 'notes' : 'files'; const routePath = isShowingNotes ? 'notes' : 'files';
const itemSingleLabel = isShowingNotes ? 'note' : 'file'; const itemSingleLabel = isShowingNotes ? 'note' : 'file';

View File

@@ -13,13 +13,20 @@ export default function SearchFiles({}: SearchFilesProps) {
const searchTimeout = useSignal<ReturnType<typeof setTimeout>>(0); const searchTimeout = useSignal<ReturnType<typeof setTimeout>>(0);
const closeTimeout = useSignal<ReturnType<typeof setTimeout>>(0); const closeTimeout = useSignal<ReturnType<typeof setTimeout>>(0);
const dateFormat = new Intl.DateTimeFormat('en-GB', { const dateFormatOptions: Intl.DateTimeFormatOptions = {
year: 'numeric', year: 'numeric',
month: 'long', month: 'long',
day: 'numeric', day: 'numeric',
hour: 'numeric', hour: 'numeric',
minute: '2-digit', minute: '2-digit',
}); };
// Force timeZone to UTC for the server rendering
if (typeof window === 'undefined') {
dateFormatOptions.timeZone = 'UTC';
}
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
function searchFiles(searchTerm: string) { function searchFiles(searchTerm: string) {
if (searchTimeout.value) { if (searchTimeout.value) {

View File

@@ -1,6 +1,6 @@
services: services:
website: website:
image: ghcr.io/bewcloud/bewcloud:v2.4.0 image: ghcr.io/bewcloud/bewcloud:v2.4.1
restart: always restart: always
ports: ports:
- 127.0.0.1:8000:8000 - 127.0.0.1:8000:8000

View File

@@ -22,7 +22,14 @@ export default function Articles({ initialArticles }: ArticlesProps) {
const sessionReadArticleIds = useSignal<Set<string>>(new Set()); const sessionReadArticleIds = useSignal<Set<string>>(new Set());
const isFilterDropdownOpen = useSignal<boolean>(false); const isFilterDropdownOpen = useSignal<boolean>(false);
const dateFormat = new Intl.DateTimeFormat('en-GB', { dateStyle: 'medium' }); const dateFormatOptions: Intl.DateTimeFormatOptions = { dateStyle: 'medium' };
// Force timeZone to UTC for the server rendering
if (typeof window === 'undefined') {
dateFormatOptions.timeZone = 'UTC';
}
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
async function refreshArticles() { async function refreshArticles() {
if (isRefreshing.value) { if (isRefreshing.value) {

View File

@@ -57,7 +57,14 @@ export default function Feeds({ initialFeeds }: FeedsProps) {
const feeds = useSignal<NewsFeed[]>(initialFeeds); const feeds = useSignal<NewsFeed[]>(initialFeeds);
const isOptionsDropdownOpen = useSignal<boolean>(false); const isOptionsDropdownOpen = useSignal<boolean>(false);
const dateFormat = new Intl.DateTimeFormat('en-GB', { dateStyle: 'medium', timeStyle: 'short' }); const dateFormatOptions: Intl.DateTimeFormatOptions = { dateStyle: 'medium', timeStyle: 'short' };
// Force timeZone to UTC for the server rendering
if (typeof window === 'undefined') {
dateFormatOptions.timeZone = 'UTC';
}
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
async function onClickAddFeed() { async function onClickAddFeed() {
if (isAdding.value) { if (isAdding.value) {