-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect timezone conversion for 'date' frontmatter #1615
Labels
bug
Something isn't working
Comments
I think this also reveals a need for two things:
I think including a datetime library (like Luxon) is the way to go. benefits are:
|
baodrate
added a commit
to baodrate/quartz
that referenced
this issue
Dec 11, 2024
Use Luxon to parse date/datetime strings. This avoids the `Date.parse`'s inconsistency between date-only (assumed UTC) and datetime (assumed local timezone) strings. (closes jackyzha0#1615) It also allows the date string's timezone to be carried along with the DateTime object, producing more friendly and semantically-correct timestamps.
baodrate
added a commit
to baodrate/quartz
that referenced
this issue
Dec 11, 2024
Use Luxon to parse date/datetime strings. This avoids the `Date.parse`'s inconsistency between date-only (assumed UTC) and datetime (assumed local timezone) strings. (closes jackyzha0#1615) It also allows the date string's timezone to be carried along with the DateTime object, producing more friendly and semantically-correct timestamps.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
If you specify the
date
frontmatter value in ISO format (e.g.2024-11-16
) with no time (the default format for Obsidian 'date' file property), the JSDate()
constructor incoerceDate
(link) interprets that as midnight UTC on the day given, whereas most other formats get interpreted in the local timezone.The result for me (eastern timezone, GMT-5/-4) is that if I specify a date file prop in Obsidian, the resulting page built by Quartz shows the date as the previous day to the one I specified.
To Reproduce
Steps to reproduce the behavior:
content/
with an ISO format date in the frontmatter, e.g.date: 2024-11-16
npx quartz build --serve
Expected behavior
If the frontmatter date is specified with no time component, it should show as the same day in the built page.
Screenshots and Source
Desktop (please complete the following information):
node
Version: v22.9.0npm
version: 10.8.3Additional context
Here's a demo of the basic problem:
Here is a draft PR illustrating the fix I'm using in my own version: #1614
Date
constructor is guaranteed to be consistent for all platforms.A better fix might involve adding a datetime library to the project, but I'm new to Quartz so I don't have a very valuable opinion here.
Hope this was helpful, and thanks so much for working on this great project ❤️
The text was updated successfully, but these errors were encountered: