Giter Site home page Giter Site logo

Comments (7)

ethlo avatar ethlo commented on June 2, 2024

I have investigated this a bit, and the problem is that this library depends on the Java 8 java.time library which does not support leap seconds. This is very evident if you look at the `ChronoField class which contains this code:

SECOND_OF_MINUTE("SecondOfMinute", ChronoUnit.SECONDS, ChronoUnit.MINUTES, ValueRange.of(0L, 59L), "second"),

There is no support for holding such a value in the underlying library, and thus I have no straight-forward path to implement this.

As you can see this will also fail:

final String leapSecondUtc = "1990-12-31T23:59:60Z";
OffsetDateTime.parse(leapSecondUtc);

from itu.

ethlo avatar ethlo commented on June 2, 2024

I have a PR ready here: #5

All it really does is to ignore the 60-second value and replace it with 59 if the month, date, hour and second dictates that this might be a valid leap-second date-time. This may solve your issue if all you need is for the parser to not bork.

Please let me know what you think.

from itu.

Megaprog avatar Megaprog commented on June 2, 2024

I have investigated this a bit, and the problem is that this library depends on the Java 8 java.time library which does not support leap seconds. This is very evident if you look at the `ChronoField class which contains this code:

SECOND_OF_MINUTE("SecondOfMinute", ChronoUnit.SECONDS, ChronoUnit.MINUTES, ValueRange.of(0L, 59L), "second"),

There is no support for holding such a value in the underlying library, and thus I have no straight-forward path to implement this.

As you can see this will also fail:

final String leapSecondUtc = "1990-12-31T23:59:60Z";
OffsetDateTime.parse(leapSecondUtc);

There is a way to parse leap second by java.time look at: https://stackoverflow.com/a/55310635/1306553

from itu.

ethlo avatar ethlo commented on June 2, 2024

Yes, I'm well aware, thank you. However, there is no way to store the result of it, as OffsetDateTime does not support any values outside of [0-59]. ITU can easily parse the number 60 as well as 59 (and it currently does), however, the error occurs when you try to put those values into OffsetDateTime.

from itu.

Megaprog avatar Megaprog commented on June 2, 2024

ok then

from itu.

ethlo avatar ethlo commented on June 2, 2024

Hi again! I was curious what is your use-case for this. How are you encountering these leap-second date-times? Will this patch work for you?

from itu.

ethlo avatar ethlo commented on June 2, 2024

This has now been solved by introducing a LeapSecondException which is thrown to signal that there was a leap second that was attempted to be parsed. This change has now been released in version 1.3.0.

from itu.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.