Comments (7)
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.
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.
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.
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.
ok then
from itu.
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.
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)
- time-secfrac should have at least one digit
- Support Java Modules HOT 3
- Support OSGI HOT 3
- Example in the docs is wrong HOT 1
- Support lowercase 't' and 'z' plus space character in the date format HOT 1
- Valid formats not parsed correctly HOT 5
- Invalid date time being accepted HOT 1
- Improve leap second detection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from itu.