cosmicsoup has asked for the wisdom of the Perl Monks concerning the following question:

I want to be able to take a date/time and convert into a tandem epoch and then reverse. Convert a tandem epoch to date/time. Is there a perl module that can do this?

Replies are listed 'Best First'.
Re: Perl tandem time conversion
by fglock (Vicar) on Aug 22, 2002 at 19:07 UTC

    No results for "tandem epoch" on google

    Did you check Date::Tie and other Date modules?

      Wow! You'll not believe this. I just found out that tandem time converts from 4700BC in micro seconds.

        Can you please cite us a reference for this 4700 BC number? I find it hard to believe anyone would express time this particular way.

      I've search google up and down and I cannot find anything on this. I've searched on "tandem epoch time", tandem time conversion, tandem epoch, and so on..
Re: Perl tandem time conversion
by richardX (Pilgrim) on Aug 22, 2002 at 20:07 UTC
    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
      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

Re: Perl tandem time conversion
by waswas-fng (Curate) on Aug 22, 2002 at 19:16 UTC
    What do you mean by Tandem Epoch? I have never heard of that before.

    -Waswas
      Tandem has it's own way of doing its own date/time calculation. For example, todays date looks like this in tandem epoch: 2.118967344e+17. Tandem has a DB time conversion that can be called straight from a the database. But I have data files with this date that I need to convert and I do not have access to a tandem database.
        give us a couple examples of the tandem <=> unix epoch conversion maybe we could come up with a simple coversion for you.

        -Waswas