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:
@@ -66,13 +66,9 @@ export default function MainExpenses({ initialBudgets, initialExpenses, initialM
|
||||
const dateFormatOptions: Intl.DateTimeFormatOptions = {
|
||||
year: 'numeric',
|
||||
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 thisMonth = new Date().toISOString().substring(0, 7);
|
||||
|
||||
Reference in New Issue
Block a user