Comments (7)
This is intentional and (while not yet in the currently released version) documented. Can you clarify what is this issue about? I would like to close this issue if your concern is simply a missing documentation.
The core rationale is that you can assume that there is no such thing as a leap second; the exception is when you actually get a leap second (:60
in the formatted string or >=1 fractional seconds), in which case it behaves like an extra fractional second following the original second. Only when you want to check if it were actually a leap second, you can look at the excess fractional seconds or (in the future) convert from the leap second to the linear scale like TAI and vice versa.
from chrono.
The undelrying issue I am experiencing is this: I am parsing ASN.1 UTCTime values, which have the format you see in my original example, except they don't allow leap seconds (60
in the second value), while chrono's %S
format does. I then did the natural thing, which was to write .second() >= 60
and error out in that case, however, obviously that case is never encountered, because the data is in nanoseconds()
.
So, I suppose I have two questions/comments:
- The fact that
Display
showed:60
but.seconds()
wasn't60
was confusing. - Is there some other way I should reject values for which
%S
parses60
that's better thand.second() >= 59 && d.nanosecond() > 0
?
from chrono.
- I feel this is basically a documentation problem, which I'd like to resolve. I already mentioned that
Timelike::second
always returns a number less than 60 andTimelike::nanosecond
would represent a leap second, but any elaboration would be welcoming (I planned to do so eventually). d.nanosecond() >= 1_000_000_000
should be sufficient to detect a leap second. Would a methodTimelike::is_leap_second
be good to have? Having a magic number is not very good but I had no concrete example for that method until now.
from chrono.
is_leap_second()
would be a great solution, it'd be more readable and let me delete several lines of comments :-)
from chrono.
Renamed this issue.
Adding something like Timelike::is_leap_second
seems easy?
from chrono.
@alex -- it's been a while. Is this still of interest to you?
from chrono.
I'm no longer using Chrono for this application, so it doesn't impact me directly.
I do think it'd be valuable to have an is leap second API though!
from chrono.
Related Issues (20)
- Verification of published packages HOT 2
- `gh-pages` branch HOT 3
- Releases has problematic naming of 0.4.8 release which puts it at the top HOT 3
- 0.4.37 semver-incompatibly removes trait bounds on `DateTime` HOT 10
- How do I get the raw underlying bytes of a `NaiveDate` HOT 4
- Parsing from string to DateTime - input is not enough for unique date and time HOT 3
- TimeDelta always returning a PT in seconds HOT 2
- NaiveDate::years_since wrong documentation
- Saturating operations HOT 9
- Datetime Parse Error when converting rfc2822 date to chrono Datetime HOT 2
- Extra slow Utc to Local conversion HOT 6
- Wasm support for NaiveTime, NaiveDate and alike HOT 2
- Bincode 2.0.0 support HOT 2
- Need Duration to Represent Time in Months/Years HOT 1
- DelayedFormat: Panic in rendering HOT 5
- Err(ParseError(TooShort)) when parsing datetime with trailing 0 HOT 4
- Support for `24:00:00` in `DateTime` Parsing HOT 2
- Century cutoff for %y undocumented
- Add (try_)from_secs_f64, (try_)from_millis_f64, as_millis_f64 and as_secs_f64 to TimeDelta HOT 1
- No serde impls for Months 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 chrono.