Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] dates: use UTC to represent naive date times
(see also the previous commit) The issue --------- Steps to reproduce: - change your machine timezone to Jakarta - enter "3/8/2023" in a cell => it becomes "3/7/2023" Other steps to reproduce: - change your machine timezone to Jakarta - npm run test => some tests are failing. Spreadsheet date times are naive date times, they do not carry any timezone information. A date(time) in spreadsheet is just a number with a format after all. We are currently using javascript native Date objects everywhere in the code to represent spreadsheet dates. And we are mixing UTC (new Date(timestamp)) and localized Dates (new Date(year, month, day, ...)) at some places. This is a mistake. Because of an (un)lucky combination of mistakes, it mostly works by chance for most timezones. But going back to the faulty Jakarta case: one can notice that INITIAL_1900_DAY is UTC+0707 while INITIAL_JS_DAY is UTC+0700 (7 minutes offset). The timezone offset changed over time. Some of the mistakes where we mix up things: - INITIAL_1900_DAY is localized, but INITIAL_JS_DAY is UTC. - numberToJsDate: we create the date from the value as if it was UTC, but then set the time as if it was localized. This commit ----------- The idea to fix the issue is to avoid mixing localized and UTC Dates. To represent naive date times, we will always use UTC Date objects. closes #3397 Task: 3666703 X-original-commit: 651f9bb Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com> Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
- Loading branch information