-
Notifications
You must be signed in to change notification settings - Fork 31
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
NorwegianDateUtil.isHoliday does not handle non-Europe/Oslo timezones (e.g. jvm default timezone) #30
Comments
But you ask isHoliday with an date at |
I would be great to rework the api in NoCommons to use |
Because its the first hour of the 17th of may in norwegian time! as shown in the created |
But you enter what is equal to If you can spot a code change in NoCommons, please do not hesitate to create a PR. :) |
|
To resolve anything involving the years, days, and so on from milliseconds from epoch, one must provide a TimeZone. If the API permits you to omit the TimeZone, some assumption must be made. The Here is a little more involved code example:
Damn, I hate that old Date/Calendar API with a passion! |
My expectations here seem to be off with how this is actually implemented 😄 If this was a lib you queried for if a date was the 17th of may I would agree! As this is a lib you query for whether a given date is a norwegian holiday or not, I expected the test I provided to pass, with the argument being that even if I bring my program over to the UK where the default jvm timezone would be GMT, the same point in linear time is still a norwegian holiday. But I see now that the code does not really take time zones into consideration. This is a pain with the old Date apis, and would probably be a lot easier to handle with the new |
I would argue that if I am in UK, it is 10PM on the 16th of May, and I query "is now a holiday in Norway", I would expect the answer to be "yes". So I agree with @torgeir's expectations. Ignoring any Einsteinian relativistic effects 😄 |
Exactly, if you run a |
Yes, If I am calling someone in Norway from UK on May 16 10PM, and asks her if now is a holiday, I would get "yes" back. If I have some kind of application with a rule that says "never bother Norwegians in their holidays", and I run that application on the other side of the planet, I would expect that application not to send any SMSs during when Norway celebrates their constitution day. |
Put another way; As someone living abroad, you are of course entitled to celebrate the norwegian constitution day whenever your country reaches the 17th of the month, but that does not change when Norwegians at home celebrate their holiday. |
I do see your point. But its not designed that way. Put simply: if the toString of the date you ask with is 16th of may, then it probably is read as that and not as any thing else. 🤷♂️ edit: Sidenote: Then lets write an api that is capable of doing that. But then we need to ditch Date from util and sql and use java.time. |
We had issues with timezones as well, and decided to implement one that use LocalDate:
|
A test similar to the following fails on my end:
I would argue that the 17th of may is a norwegian holiday even if the jvm timezone is GMT 😉
The text was updated successfully, but these errors were encountered: