astro:db
: TimeStamps stored using NOW
(in UTC) are being translated to their Local Time value making the JavaScript value of the Date
object inaccurate
#10964
Labels
- P5: urgent
Fix build-breaking bugs affecting most users, should be released ASAP (priority)
pkg: db
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Date values created with the
NOW
constant fromastro:db
(LibSQL valueCURRENT_TIMESTAMP
) are being treated as the local date value from the tables that useDate
columns. Because the timestamp in the database is not stored with any timestamp info, the date will be treated as the local time of the client parsing the value.What's the expected result?
Personally I would expect one of two things:
Option 1: I would expect the date to be stored in whatever timezone it was created in (I think this might be impossible due to the way that they are stored - but I am no SQLite expert so I could be wrong)
Option 2: The date should be returned as a string (not parsed by astro, similar to the example when using the code
db.select({ date: NOW })...
), and the user should be responsible for adding the correct timestamp.Link to Minimal Reproducible Example
When running the reproduction you must use --remote for the code to work (otherwise you would need to replace line
13
of thesrc/index.astro
file with the coderows: [{ date, localTime }],
due to the way that the query is parsed on remote vs local / from file (will open a separate bug for this issue).https://github.com/timsexperiments/astro-db-now-reproduction
Deployed Version: https://astro-db-now-reproduction.pages.dev/
Participation
The text was updated successfully, but these errors were encountered: