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

View File

@@ -44,14 +44,21 @@ export default function ListFiles(
fileShareId,
}: ListFilesProps,
) {
const dateFormat = new Intl.DateTimeFormat('en-GB', {
const dateFormatOptions: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'long',
day: 'numeric',
hour12: false,
hour: '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 itemSingleLabel = 'file';

View File

@@ -26,14 +26,21 @@ export default function ListFiles(
isShowingNotes,
}: ListFilesProps,
) {
const dateFormat = new Intl.DateTimeFormat('en-GB', {
const dateFormatOptions: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'long',
day: 'numeric',
hour12: false,
hour: '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 itemSingleLabel = isShowingNotes ? 'note' : 'file';

View File

@@ -13,13 +13,20 @@ export default function SearchFiles({}: SearchFilesProps) {
const searchTimeout = 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',
month: 'long',
day: 'numeric',
hour: 'numeric',
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) {
if (searchTimeout.value) {