MOO-cows Mailing List Archive

[Prev][Next][Index][Thread]

Re: The reverse of ctime()



> Does a function exist (or does someone know the code for such a beast) to
> take time in a human readable format and convert it to the internal time
> format (ie; number of seconds since 1/1/1970) ?
> 
> The function need not parse a command line, it would be cool if it could
> just take a time, day, month, year.

I made a patch some time back to add two builtins to the MOO server for 
timezone and time-conversion functions.  ctime_tz() is like ctime() but it 
also takes a unix-style timezone spec and returns the time in that 
timezone.  mktime_tz, which it sounds like is what you're looking for, 
takes a timezone, year, month, day, hour, minute, and second and returns 
the appropriate time()-value.

The patch is on my patch archive 
(ftp://ftp.crl.com/users/ri/riche/MOO/patches).  It's for 1.7.8, but 
shouldn't require much change on later servers..

There's also a routine on LambdaCore's $time_utils (:from_ctime), if you
don't need the timezone-handling..

-R
-------------------------------------------------------------------------------
      Alex Stewart - riche@crl.com - Richelieu @ Diversity University MOO
                          http://www.crl.com/~riche/
            "Difficult answers lead to intelligent questions."



Home | Subject Index | Thread Index