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

Re: [MacPerl] Strange time output



At 14:24 -0500 1/11/00, Chris Nandor wrote:
>At 14.08 -0500 2000.01.11, Ronald J Kimball wrote:
>>> Can anyone tell me why this happens? $year is formatted to be two digits I
>>> can't see how I suddenly get three... and 100 at that.
>>
>>The documentation can tell you why this happens.  Haven't you read it?
>
>I am not so sure it does tell you, actually.  At best, it seems to me, it
>assumes you know or have access to other sprintf documentation.
>
>--

The documentation tells one that the year position in the list output by
localtime is actual year - 100, not a two-digit year.

The documentation also, I think, tells one that in sprintf and friends, the
specification %02d says to use *at least* two digits to represent the
number and to zero fill if there is only one digit.  If there are 6 digits
(unlikely for years) they will appear.

At 19:18 +0100 1/11/00, Martin D. wrote:
>($day, $month, $year) = (localtime) [3,4,5];
>$timestamp = sprintf("%02d-%02d-%02d\n", $year, $month+1, $day);
>
>print "$timestamp";
>
>this produces:
>100-01-11

  --John (who long has said that while Unix provides the tools to handle
Y2K properly (Y2038 is another matter), it's still possible to produce
results which have Y2K problems by misusing the tools Unix provides.
Actually, I mostly said that about MacOS)
-- 
John Baxter   jwblist@olympus.net      Port Ludlow, WA, USA

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org