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

"Illegal instant due to time zone offset transition" #15

Closed
marcushg opened this issue Oct 18, 2016 · 3 comments
Closed

"Illegal instant due to time zone offset transition" #15

marcushg opened this issue Oct 18, 2016 · 3 comments
Assignees

Comments

@marcushg
Copy link

Hi, first of all thanks for saving us the trouble to deal with random date generation.

From time to time we run into an 'Illegal instant due to time zone offset transition' exception due to generating a date which happens to "not exist".

Should be easy to reproduce like this:

import com.fortysevendeg.scalacheck.datetime.joda.ArbitraryJoda._
import org.scalacheck.Arbitrary.arbitrary
import org.joda.time.DateTime

(1 to 10000).map(_ => arbitrary[DateTime].sample)

sometimes results in e.g.

org.joda.time.IllegalInstantException: Illegal instant due to time zone offset transition (daylight savings time 'gap'): 173829578-03-26T02:52:52.521 (Europe/Berlin)
  at org.joda.time.chrono.ZonedChronology.localToUTC(ZonedChronology.java:157)
  at org.joda.time.chrono.ZonedChronology.getDateTimeMillis(ZonedChronology.java:122)
  at org.joda.time.chrono.AssembledChronology.getDateTimeMillis(AssembledChronology.java:133)
  at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:257)
  at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:198)
  at org.joda.time.DateTime.<init>(DateTime.java:476)
[....]

The link above has more details on the cause and some ideas on mitigating it, though I am not sure what steps would be appropriate in this case to still have completely random dates. Thanks!

@noelmarkham
Copy link
Collaborator

Hi Marcus,

Thanks for this, I'll take a look at reproducing this and will let you know ASAP. Great to see that it's been useful so far.

Cheers
Noel

noelmarkham added a commit that referenced this issue Nov 28, 2016
Increased the number of ScalaCheck tests to expose this issue, too.

Fixes #15.
@noelmarkham noelmarkham self-assigned this Nov 28, 2016
@noelmarkham
Copy link
Collaborator

Hi @marcushg

I've published a new SNAPSHOT containing a fix for this. I expect to publish a release in the next day or two.

Find it at https://oss.sonatype.org/content/repositories/snapshots/com/fortysevendeg/scalacheck-datetime_2.12/0.2.1-SNAPSHOT/scalacheck-datetime_2.12-0.2.1-SNAPSHOT.jar

It's also published for Scala 2.10 and 2.11.

Any issues please let me know, and please keep raising issues if this library is useful.

Cheers
Noel

@marcushg
Copy link
Author

Thanks alot @noelmarkham! Tried the snapshot version quickly and it works as expected (i.e. I can't reproduce my error) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants