in reply to Re: Timegm and timelocal
in thread Timegm and timelocal

I have question for this part of your code print (($t2+3600-$t1)%3600 Why again do I need to add 3600 to $t2

Replies are listed 'Best First'.
Re^3: Timegm and timelocal
by Skeeve (Parson) on Jun 08, 2007 at 10:56 UTC

    You don't need to, but if you do, you don't need to check for negative values afterwards.

    You can replace this by:

    my $r= $t2-$t1; $r+= 3600 if $r<0;

    This code may even be faster because you don't need to divide by 3600.


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e