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

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.
  • Comment on Re: (mitd)Re: Re: Re: time & localtime() function Q?

Replies are listed 'Best First'.
Re: Re: (mitd)Re: Re: Re: time & localtime() function Q?
by Boldra (Curate) on Nov 23, 2001 at 01:30 UTC
    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
Re: Re: (mitd)Re: Re: Re: time & localtime() function Q?
by mitd (Curate) on Nov 23, 2001 at 01:37 UTC
    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!'