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

[MacPerl] time, date, and timezone



At 16:14 -0700 98/08/25, Brian "L." Matthews wrote:
> |> $date_command = "/bin/date";
> |I suggest you translate the code to "native" perl.  Try:
> |  $date_command = localtime();
>
> While the suggestion is good, the implementation isn't. Note that
> $date_command is the *command to get the date*, not the date itself.
>
> $timestamp = `$date_command`;


*SIGH*; yes.  I blitzed.
The original blechiness was more extensive than I gave it credit for
:-|~~~~~~~

You'll need to hunt for the places where $date_command is run and fix those
directly.

> Also, /bin/date outputs a newline at the end of the date while localtime
> doesn't.

That part I did get right the first time around :-)

> unless another script is analyzing the log, in which case it might
> expect /bin/date's format

Which, of course, would be even less portable :-(

But you could always fake in the timezone field if need be, as pointed out
by others.  Either hardwire your actual timzone (yurk) or put in a
placeholder field...

Query:
Timezone is generally an environment variable in Unix; it doesn't appear to
be an environment variable in MacPerl.  And from ctime.pl:

    # There's no portable way to find the system default timezone.

Obviously localtime() calculates the timezone because localtime() adjusts
its output accordingly.  But how do _I_ retrieve that information directly?
I could get the offset by calculating the difference between GMT and
localtime (stealing shamelessly from Local.pm?; ugh) but is there another
(lazy :-) way to get the local time zone directly from the Mac? Does the
Mac even store a "symbolic" (or offset) timezone? (The Date/Time control
panel deals with timezones by city...).

- Vicki
---
Vicki Brown, vlb@cfcl.com        |\      _,,,---,,_
Journeyman Sourceror      ZZZzz /,`.-'`'    -.  ;-;;,_
Scripts & Philtres             |,4-  ) )-,_. ,\ (  `'-'
http://www.cfcl.com/~vlb      '---''(_/--'  `-'\_)
P.O. Box 1269 San Bruno, CA  94066

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