Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Logical ways to calculate being within two times

by BrowserUk (Pope)
on Nov 28, 2016 at 19:47 UTC ( #1176727=note: print w/replies, xml ) Need Help??


in reply to Re: Logical ways to calculate being within two times
in thread Logical ways to calculate being within two times

One possible caveat of the epoch time calculation.

If you set a time that happens to coincide to the minute, with the subtraction of a leap second, then the until loop may never terminate.

The solution is to add 30 rather than 60 each iteration.

Of course, if your processor doesn't use NTP or some similar method to synchronise its system clock, the problem is probably moot.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^2: Logical ways to calculate being within two times

Replies are listed 'Best First'.
Re^3: Logical ways to calculate being within two times (leaps)
by tye (Sage) on Nov 28, 2016 at 21:26 UTC

    My experience says that leap seconds do not impact epoch time (note that after inserting 26 leap seconds, the epoch time at the top of a minute is still currently a multiple of 60, whether using UTC or not). And, when you think about it, they can't.

    Leap seconds are not scheduled very far in advance but epoch times for years in the future have been being used for years in the past. So leap seconds can't impact (Unix-style) epoch time values else past calculations of future dates would become inaccurate.

    - tye        

      My experience says that leap seconds do not impact epoch time ... And, when you think about it, they can't.

      You missed the point. I was not describing a problem with epoch times per se; but rather my method of deriving them.

      The loop relies upon hitting every minute so as to ensure it will terminate. When the required minute is reached.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
      In the absence of evidence, opinion is indistinguishable from prejudice.

        The code hits each minute by adding 60 to epoch time values. So a leap second can't cause that code to miss a particular minute. Had the code done something like sleep(60), then a negative leap second or even just a bit of the system being busy could trip it up.

        - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1176727]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2020-10-29 02:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (266 votes). Check out past polls.

    Notices?