-
Notifications
You must be signed in to change notification settings - Fork 328
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
Dates from data/*.yml file all have off-by-one errors on machines with american timezones #726
Comments
Interestingly, post.date dates are fine on that machine (no one-off-error). |
I bet java.util.Date is responsible for this. It's a shame that Freemarker is not using java.time.LocalDate (Java 8+) yet. May java.util.Date burn in hell, where it was forged. |
Based on the Yaml spec it appears those date values will have a time of 00:00:00 (start of the day) and UTC timezone so when the local timezone of the machine is applied (i.e. -05:00) you get a date of the previous day. If you add |
@jonbullock Any chance JBake can just fix this for us out the box? (*) Requires at least Java 8, but I suspect all these techs now require at least Java 8 (if not 11). |
Yeah still working towards that goal, last comment was a dump of my progress so far. |
OK so after more investigation, Snakeyaml is using the same timezone as the rest of JBake. I was curious as to why this issue didn't seem to affect other dates (i.e. dates for content files) but after further research it does affect them in the same way. However it's probably not been noticed due to the content having a time component that meant the timezone offset didn't affect the day component. I looked into option B and it's quite straight forward to use LocalDate in Snakeyaml, however this type is not yet supported in Freemarker so changes would be required to templates. There is the option for JBake to explicitly override the local TimeZone (maybe via jbake.properties) in similar fashion to what it does with locale? |
Thank you for the investigation, Jon. Much appreciated. I've opened a discussion the Freemarker mailing list about LocalDate support.
I am happy to make such changes. It would be great to have a jbake.properties option to turn this behavior on (preferJavaTime=true ?) even if it's just for yaml. Anything to ban the use of java.util.Date.
Not sure what you mean here. I think that if jbake.properties fixes a timezone, then all techs (snakeyaml, freemarker, etc) should be explicitly set to use that. If it doesn't fix a timezone, they should all be using the default timezone of the process (= of the OS). In both cases, java.util.Date's won't suddenly change timezone, because there will only be one timezone. |
@jonbullock is the fix from your fork coming to blessed? |
Fixes #726 - Sets TimeZone for Freemarker template engine
The automatic publisher of the optaplanner.org website has off-by-one-errors for dates. Locally I cannot reproduce this bug.
For example, all the event dates published on optaplanner.org live are wrong:
But in the events.yml file, they are correct:
I suspect this because of the timezone setting of the virtual machine and/or OS. I managed to reproduce locally by doing this:
The text was updated successfully, but these errors were encountered: