Giter Site home page Giter Site logo

Comments (7)

lifthrasiir avatar lifthrasiir commented on August 27, 2024

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.

alex avatar alex commented on August 27, 2024

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:

  1. The fact that Display showed :60 but .seconds() wasn't 60 was confusing.
  2. Is there some other way I should reject values for which %S parses 60 that's better than d.second() >= 59 && d.nanosecond() > 0?

from chrono.

lifthrasiir avatar lifthrasiir commented on August 27, 2024
  1. 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 and Timelike::nanosecond would represent a leap second, but any elaboration would be welcoming (I planned to do so eventually).
  2. d.nanosecond() >= 1_000_000_000 should be sufficient to detect a leap second. Would a method Timelike::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.

alex avatar alex commented on August 27, 2024

is_leap_second() would be a great solution, it'd be more readable and let me delete several lines of comments :-)

from chrono.

pitdicker avatar pitdicker commented on August 27, 2024

Renamed this issue.

Adding something like Timelike::is_leap_second seems easy?

from chrono.

djc avatar djc commented on August 27, 2024

@alex -- it's been a while. Is this still of interest to you?

from chrono.

alex avatar alex commented on August 27, 2024

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)

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.