[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] date functions



Peter Prymmer:
>dfbeck@sandia.gov
>Subj:	Re: [MacPerl] date functions
>
>David Beck writes:
>
>
>>I have several Perl scripts written for a unix platform that makes calls to
>>'date' using various +format options. Does anyone have a module or code
>>fragment suitable for use in MacPerl that could handle this call with
>>suitable changes to the original code (rather than a complete rewrite using
>>time(), etc.)?
>
>There are dozens.  Check out:
>
> http://www.perl.com/CPAN/modules/by-category/06_Data_Type_Utilities/Time/
>
>By the way on all platforms that support perl 5* the easiest way
>to do X-platform timestamps is:
>
>   print(scalar(localtime()));

And the easiest way (ie. it comes with MacPerl) to get formats strings
similar to Unix "date" is probably to use strftime() in the POSIX library.
It may not necessarily support _all_ the same format options as date, but
most should be there, so converting from date to strftime should be
straightforward.
$s = `date +"%b %e %T %Y"`
simply becomes (with use POSIX):
$s = strftime("%b %e %T %Y",localtime) ."\n";

-Lasse



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch