Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

(mitd)Re: Re: Re: time & localtime() function Q?

by mitd (Curate)
on Nov 22, 2001 at 23:24 UTC ( #127003=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: time & localtime() function Q?
in thread time & localtime() function Q?

If you mean you are writing/testing code on windows and uploading to Unix then don't worry things will work as expected ie localtime() will do the right thing. time and localtime() in Perl are really just 'wrappers' around lower level system library calls of the same name. Most (gulp) modern OSes support theses calls,

mitd-Made in the Dark
'Interactive! Paper tape is interactive!
If you don't believe me I can show you my paper cut scars!'


Comment on (mitd)Re: Re: Re: time & localtime() function Q?
Re: (mitd)Re: Re: Re: time & localtime() function Q?
by Gerryjun (Scribe) on Nov 23, 2001 at 00:41 UTC
    what im realy interested is on the time() function and not
    so much on localtime(), im in editing the time()
    value before i use it in the localtime() to translate.

    To do what i want i need to understand how localtime()
    translate the time() value? to see if i can add or
    subtract to get the value that i want or date that i want!

    i know that my problem could be solved by creating a table
    that will correspond to each week number, but i would like
    to achieve this the mathematical way.
      Time usually returns the number of seconds that have passed since January 1st 1970 (GMT). Check it on your platform by using perldoc, type "perldoc -f time" on a command line. You might find the (standard) module Time::Local useful, because it converts arbitrary dates into epoch time, eg;
      perl -MTime::Local -e '$time = timegm(0,0,0,1,0,70); print"$time\n"'
      Which will print out 0 if your computer uses the standard epoch.

      or try:
      perl -MTime::Local -e '$time = timelocal(40,46,3,9,8,101); print" $tim +e\n"'
      which will print out "1000000000", because back in November (3:46:40 seconds, November 9th 2001), epoch times started being ten digits.


      - Boldra
      You really need to read about the perl modules I have already given you. These will allow you to manipulate date/time in a portable way. If you pre-calculate reference times based on system time they will or may not be portable across OSes because EPOCH times may differ. Date:Calc will make your life much easier.

      mitd-Made in the Dark
      'Interactive! Paper tape is interactive!
      If you don't believe me I can show you my paper cut scars!'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2014-12-18 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (69 votes), past polls