Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Perl tandem time conversion

by richardX (Pilgrim)
on Aug 22, 2002 at 20:07 UTC ( [id://192157]=note: print w/replies, xml ) Need Help??


in reply to Perl tandem time conversion

I use ISO time stamps and here is my code:
sub iso_timestamp { # create a string containing todays date and time in ISO format my $t = shift || time; my ($sec, $min, $hour, $mday, $mon, $year, $wday,$yday,$isdst) = localtime $t; $year += 1900; $mon += 1; return sprintf ("%04d" . "/"."%02d". "/"."%02d". " "."%02d". ":"."%0 +2d". ":"."%02d", $year, $mon, $mday, $hour, $min, $sec); } # end of iso_timestamp
Richard

There are three types of people in this world, those that can count and those that cannot. Anon

Replies are listed 'Best First'.
Re: Re: Perl tandem time conversion
by cosmicsoup (Beadle) on Aug 22, 2002 at 20:38 UTC
    Tandem time starts in 4700BC in micro seconds.

      Tandem time starts in 4700BC in micro seconds.

      This is the whackiest time format I have ever heard of, I wonder what they were taking^Wthinking.

      You want to convert to epoch seconds, then add 4700 + 1970 years worth of seconds and then multiply by 1000.

      The 4700+1970 years worth of seconds is the sticky part- you have to take into account all the leap years and pretend that the calender doesn't change as you go back. I would bet they have a pre-calculated constant they cut 'n paste around.

      See Time::Local and localtime() for converting to/from epoch seconds.

      --
      Until you've lost your reputation, you never realize what a burden it was or what freedom really is. -Margaret Mitchell

        Also, remember that there was no year 0. (not that our current calendar was in use back then, but the scholars have had their say) Dec. 31, 1 BC was followed by Jan. 1, 1 AD. At least thats what I remember from the 2000/2001 end-of-the-millenium debate.

        -Blake

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-29 08:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found