Skip to content
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

Bug interpreting times in the "overlap" period during fall DST change. #166

Closed
dcosson opened this issue May 19, 2017 · 7 comments
Closed
Labels

Comments

@dcosson
Copy link

dcosson commented May 19, 2017

In testing out js-joda and comparing it to the java version, I noticed once bug. In the "overlap" period at a daylight savings boundary (e.g. fall in the US), there are two different offset values for the same time.

In the Java implementation, it works as expected:

jshell> import java.time.ZonedDateTime

jshell> ZonedDateTime.parse("2017-11-05T01:00:00-07:00[America/Los_Angeles]").toInstant().toString()
$2 ==> "2017-11-05T08:00:00Z"

jshell> ZonedDateTime.parse("2017-11-05T01:00:00-08:00[America/Los_Angeles]").toInstant().toString()
$3 ==> "2017-11-05T09:00:00Z"

jshell> ZonedDateTime.parse("2017-11-05T02:00:00-08:00[America/Los_Angeles]").toInstant().toString()
$4 ==> "2017-11-05T10:00:00Z"

js-joda interprets "2017-11-05T01:00:00-07:00[America/Los_Angeles]" as "2017-11-05T01:00:00-08:00[America/Los_Angeles]" which is actually a different time (it should be the second 1 am, i.e. it comes just after 1:59 am)

JSJoda.ZonedDateTime.parse("2017-11-05T01:00:00-07:00[America/Los_Angeles]").toInstant().toString()
"2017-11-05T08:00:00Z"
JSJoda.ZonedDateTime.parse("2017-11-05T01:00:00-08:00[America/Los_Angeles]").toInstant().toString()
"2017-11-05T08:00:00Z"
JSJoda.ZonedDateTime.parse("2017-11-05T02:00:00-08:00[America/Los_Angeles]").toInstant().toString()
"2017-11-05T10:00:00Z"

The spring doesn't have a problem in JSJoda.

Not sure if this bug belongs in js-joda or js-joda-timezone

@pithu pithu added the bug label May 21, 2017
@pithu
Copy link
Member

pithu commented May 21, 2017

Hi,

thx for reporting,

looks like a bug in the DateTimeFormatter / ZoneId Parser in the js-joda core library.

I will have a look.

pithu pushed a commit to js-joda/js-joda-timezone that referenced this issue May 25, 2017
@pithu
Copy link
Member

pithu commented May 25, 2017

Hi @dcosson

I cant reproduce the issue, neither with the latest threeten backport nor the latest jdk 8 version see groovy test script. I get the same results as with js-joda (see the 2 commits above).

A look in the threeten code says that the offset is ignored if a zone id is supplied. In case of an overlap the earlier offset is used, typically corresponding to "summer". Basically its the same behavior as described here LocalDateTime.atZone

What jdk version did you use for your jshell example ?

@dcosson
Copy link
Author

dcosson commented May 25, 2017

That's interesting I guess this bug (or maybe intentional behavior) goes pretty deep.

I tested it on the latest openjdk 9 version on docker hub, just because java 9 has jshell built-in. I ran it as: docker run -it openjdk:9-b170-jdk jshell

@dcosson
Copy link
Author

dcosson commented May 25, 2017

The line that made me think the version I'm seeing in jdk 9 is correct was in the threeten docs

It says "In an overlap there are local date-time values with two valid offsets." which makes me think that when passing in both offset and timezone (which is otherwise redundant outside of this 1 hour a year), the intention was to respect the offset if it is one of the two valid offsets within the timezone.

@pithu
Copy link
Member

pithu commented May 26, 2017

Interesting: "jdk9 early access" behaves different then jdk8 and threeten.

So i wouldn't call it a bug, but a different interpretation of an edge case. Probably your issue should go to the jdk team. The question is, why jdk9 changes the behavior for that case

@pithu pithu added question and removed bug labels May 26, 2017
@pithu
Copy link
Member

pithu commented Jul 30, 2017

I forwarded the question to threeten backport project -> ThreeTen/threetenbp#73

@pithu pithu added bug and removed question labels Sep 8, 2017
@pithu
Copy link
Member

pithu commented Sep 8, 2017

Its a bug in threeten backport and jdk8 and therefore in js-joda. its fixed in jdk9. see ThreeTen/threetenbp#73

The proposal is to prioritise the offset if zone and offset is present.

We will fix it in that way!

@pithu pithu closed this as completed in cc1ddff Sep 21, 2017
phueper pushed a commit to phueper/js-joda that referenced this issue Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants