Fix timezone issues with expenses.
I was able to reproduce the problem by setting my system to a timezone, and my `TZ` to a different one. Since it'll default to `UTC`, and to avoid having to pass it around from the system to the client (since we don't really care about the timezone), we simply force the timezone to UTC in the formatting as well, because, again, we don't store timezones or care about them for expenses. Fixes #88
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
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
|
||||||
|
|||||||
@@ -16,14 +16,10 @@ export default function ListExpenses(
|
|||||||
const dateFormatOptions: Intl.DateTimeFormatOptions = {
|
const dateFormatOptions: Intl.DateTimeFormatOptions = {
|
||||||
month: 'short',
|
month: 'short',
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
|
timeZone: 'UTC', // Expense dates are stored without timezone info, so we need to force to UTC so it's consistent across db, server, and client
|
||||||
};
|
};
|
||||||
|
|
||||||
// Force timeZone to UTC for the server rendering
|
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
|
||||||
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'>
|
||||||
|
|||||||
@@ -66,13 +66,9 @@ export default function MainExpenses({ initialBudgets, initialExpenses, initialM
|
|||||||
const dateFormatOptions: Intl.DateTimeFormatOptions = {
|
const dateFormatOptions: Intl.DateTimeFormatOptions = {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
|
timeZone: 'UTC', // Expense dates are stored without timezone info, so we need to force to UTC so it's consistent across db, server, and client
|
||||||
};
|
};
|
||||||
|
|
||||||
// Force timeZone to UTC for the server rendering
|
|
||||||
if (typeof window === 'undefined') {
|
|
||||||
dateFormatOptions.timeZone = 'UTC';
|
|
||||||
}
|
|
||||||
|
|
||||||
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
|
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
|
||||||
|
|
||||||
const thisMonth = new Date().toISOString().substring(0, 7);
|
const thisMonth = new Date().toISOString().substring(0, 7);
|
||||||
|
|||||||
@@ -53,11 +53,6 @@ export default function ListFiles(
|
|||||||
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 dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
|
||||||
|
|
||||||
let routePath = fileShareId ? `file-share/${fileShareId}` : 'files';
|
let routePath = fileShareId ? `file-share/${fileShareId}` : 'files';
|
||||||
|
|||||||
@@ -35,11 +35,6 @@ export default function ListFiles(
|
|||||||
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 dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
|
||||||
|
|
||||||
const routePath = isShowingNotes ? 'notes' : 'files';
|
const routePath = isShowingNotes ? 'notes' : 'files';
|
||||||
|
|||||||
@@ -21,11 +21,6 @@ export default function SearchFiles({}: SearchFilesProps) {
|
|||||||
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 dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
|
||||||
|
|
||||||
function searchFiles(searchTerm: string) {
|
function searchFiles(searchTerm: string) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
website:
|
website:
|
||||||
image: ghcr.io/bewcloud/bewcloud:v2.4.1
|
image: ghcr.io/bewcloud/bewcloud:v2.4.2
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- 127.0.0.1:8000:8000
|
- 127.0.0.1:8000:8000
|
||||||
|
|||||||
@@ -24,11 +24,6 @@ export default function Articles({ initialArticles }: ArticlesProps) {
|
|||||||
|
|
||||||
const dateFormatOptions: Intl.DateTimeFormatOptions = { 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);
|
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
|
||||||
|
|
||||||
async function refreshArticles() {
|
async function refreshArticles() {
|
||||||
|
|||||||
@@ -59,11 +59,6 @@ export default function Feeds({ initialFeeds }: FeedsProps) {
|
|||||||
|
|
||||||
const dateFormatOptions: Intl.DateTimeFormatOptions = { 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);
|
const dateFormat = new Intl.DateTimeFormat('en-GB', dateFormatOptions);
|
||||||
|
|
||||||
async function onClickAddFeed() {
|
async function onClickAddFeed() {
|
||||||
|
|||||||
Reference in New Issue
Block a user