Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
convert from any time in Perl to Clock Ticks.

You say that as if "Clock Ticks" were some universally defined SI time unit. But ticks of which clock?

I have a Grandfather clock that ticks once every 2 seconds, (and tocks every two on the alternate second). But it also looses around 30 minutes a day.

Conversely, the clock on my PC ticks (or maybe tocks; I've never heard it :), 2.4 billion times a second

I have been tasked with the job of handing out the current UTC time from within Perl in ticks (the epoch being 01/01/0001 00:00:00, not 01/01/1970 00:00:00).

Naively, (assuming "Clock Ticks" are seconds), you only need add the number of seconds between 0001 and 1970 to those returned by time:

print 1969*365.25*24*60*60;; 62136914400

But that figure diverges a way from the one used by your C# snippet. It seems to calculate the year as:

print 62135596800 / ( 1969*24*60*60 );; 365.242254951752

Or 365 days 5 hours 48 minutes 57 seconds.

But a quick search comes up with a bunch of different figures:

  • 365 solar days, 5 hours, 55 minutes, 12 seconds
  • 365 solar days, 5 hours 49 minutes 19 seconds.
  • 365 solar days, 5 hours, 55 minutes, 58 seconds.
  • 365 solar days, 5 hours, 48 minutes, 45 seconds.
  • 19851986 365 5 48 58 19861987 365 5 49 15 19871988 365 5 46 38 19881989 365 5 49 42 19891990 365 5 51 06
  • 365 days, 5 hours, 48 minutes, 45.19.

And that lot come from just one Wikipedia page.

And then there is the problem that up until 1582, the calender was so wrong they had to keep adding leap weeks (or was it leap months) to to stop New Year's Day from inexorably shifting its relationship with the solstices.

On top of that, the length of the day is variable.

My point is that whatever numbers you use, what you've calculated as your "epoch" is effectively a totally arbitrary point in time.

So then you have to question: why are you doing it?

1970 as used by *nix; or 1601 as used by Windows; or any of the other Notable Epochs are just as good (and bad).


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".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


In reply to Re: Calculate clock ticks since a given date by BrowserUk
in thread Calculate clock ticks since a given date by kurgan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (10)
    As of 2014-08-20 05:32 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (105 votes), past polls