Invert timezone offset sign for correct SQL datetime conversion
This commit is contained in:
1 parent
6d361e6359
commit
95cd2cc746
1 file changed
+4
-2
+4
-2
@@ -68,8 +68,10 @@ function getTimezoneOffset() {
|
|||||||
|
|
||||||
console.log(`Timezone offset for ${tz}: ${offsetHours} hours (UTC ${utcHour}:00, TZ ${tzHour}:00)`);
|
console.log(`Timezone offset for ${tz}: ${offsetHours} hours (UTC ${utcHour}:00, TZ ${tzHour}:00)`);
|
||||||
|
|
||||||
// SQL datetime() function: negative means subtract, positive means add
|
// SQL datetime() function: we need the OPPOSITE sign
|
||||||
return offsetHours > 0 ? `+${offsetHours} hours` : `${offsetHours} hours`;
|
// If local is 5 hours behind UTC, we need to ADD 5 hours to go backwards (counterintuitive but correct for SQLite)
|
||||||
|
const sqlOffset = -offsetHours;
|
||||||
|
return sqlOffset > 0 ? `+${sqlOffset} hours` : `${sqlOffset} hours`;
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
|||||||
Reference in new issue
Block a user