manual parsing of date to avoid UTC issues

This commit is contained in:
Gamosoft 2025-12-11 08:28:28 +01:00
parent 8d263f3d78
commit 90048fcd22
1 changed files with 8 additions and 1 deletions

View File

@ -3419,7 +3419,14 @@ function noteApp() {
// Format dates nicely // Format dates nicely
if (key === 'date' || key === 'created' || key === 'modified' || key === 'updated') { if (key === 'date' || key === 'created' || key === 'modified' || key === 'updated') {
const date = new Date(value); let date;
// Parse date-only strings (YYYY-MM-DD) as local dates to avoid timezone issues
if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value)) {
const [year, month, day] = value.split('-').map(Number);
date = new Date(year, month - 1, day); // month is 0-indexed
} else {
date = new Date(value);
}
if (!isNaN(date.getTime())) { if (!isNaN(date.getTime())) {
return date.toLocaleDateString('en-US', { return date.toLocaleDateString('en-US', {
year: 'numeric', year: 'numeric',