-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
tz-magic when dst-transition is near #561
base: master
Are you sure you want to change the base?
Conversation
@@ -106,13 +109,35 @@ public void testNowPlusOneDay() throws Exception { | |||
assertThat(tomorrowFromFunction, sameDay(tomorrow)); | |||
} | |||
|
|||
private int dstOffset(Date from, Date to) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is called from line 139?
But seriously that function is the essence of this PR, as it calculates the DST offset between two dates for the timezone of the JVM.
@FSchumacher , can you please clarify what behavior you want to achieve before adding In 99.42% of the cases, |
In normal times (no DST switch in the near future) the Can you tell me, where But I have to admit, that I don't feel comfortable with this hack, so if you have a better version that works in the interval 10 days before a DST switch in the local timezone, I would be happy. PS. the reason for this should be clear from the description of the PR above. |
What do you mean by What is the intended behavior when "adding 1 day"?
I think we should stick to |
The tests should pass all the time of the year. Currently they fail for about 10 days before a DST switch in the current timezone of the JVM. (At least on some instances of travis and my test vm, that I had setup for testing).
Where do you read from the code, that I add 1 day or 24 hours? The current test for timeshift uses the current date for the local timezone of the machine and adds a specified (complex) unit of time to it (that time is then parsed back from a string representation of it). The test then checks, that it is the same instant as the local current date with the same amount of time added via a different API. This seems to break when we cross the DST setting (DST switch somewhere between now and the future date).
That can hopefully fixed once I understand how to describe it properly :)
Is there a
+1 to that |
Ok. The test code is using Does it really make sense to use |
I think I now understand where the problems come from. We changed to ZonedDateTime inside of Now the test method we are talking about uses a format string which has no time zone attribute and thus the Now, if we try to change to I will try, if we can get that missing information by looking at the future date alone. |
Hello @FSchumacher , |
The reasons for this PR are still in place. We handle timezones not really correctly and therefore get flaky tests shortly before and after the dates for winter/summertime adjustments. |
Our tests (for timeshift function) started to fail shortly before a DST transition in New Yorker timezone, as the parsing of a date into LocalDateTime seems to follow different rules than adding time to a LocalDateTime instance. Therefore we now try to calculate the DST offset for the calculated time and the current time. That offset will be added to the result of the timeshift function.
Codecov Report
@@ Coverage Diff @@
## master #561 +/- ##
============================================
- Coverage 55.39% 55.39% -0.01%
+ Complexity 10191 10189 -2
============================================
Files 1046 1046
Lines 64356 64356
Branches 7299 7299
============================================
- Hits 35651 35649 -2
Misses 26196 26196
- Partials 2509 2511 +2
Continue to review full report at Codecov.
|
More discussion on can be found on https://bz.apache.org/bugzilla/show_bug.cgi?id=65217 |
Description
Calculate the DST offset in a special scenario for timeshift function tests, that cross DST switching.
Motivation and Context
Our tests (for timeshift function) started to fail shortly before a DST transition in
New Yorker timezone, as the parsing of a date into LocalDateTime seems to follow
different rules than adding time to a LocalDateTime instance.
Therefore we now try to calculate the DST offset for the calculated time and the current
time. That offset will be added to the result of the timeshift function.
How Has This Been Tested?
A test VM with a date set to 2020-03-04 has been set up and used to run ./gradlew build.
Screenshots (if appropriate):
Types of changes
Checklist: