http://qs321.pair.com?node_id=1176755


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

To guard against the infinite loop / leapsecond / 59 second minute

my $failsafe = 0; $time += 60 until localtime($time) =~ /$on_at:/ or $failsafe++ > +10_000;

Adjust the failsafe cutoff until its just large enough but not too large :) If it slows down this approach change it :) maybe use strptime

Replies are listed 'Best First'.
Re^3: Logical ways to calculate being within two times
by BrowserUk (Patriarch) on Nov 29, 2016 at 00:12 UTC

    That breaks the loop, but doesn't fix up the problem.

    Adding 30 instead of 60 prevents the problem completely and runs more quickly.


    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.

      Just came across this article this morning. Google is, instead of doing the leap second, is going to slow their clocks on their NTP servers by 0.0014% over the 10 hours before and 10 hours after the leap second.

      Also, they've opened up these servers to the public.

      ps. I changed my code with the 30 second modification.