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

Re: [MacPerl] 1900-2000 problem.



At 7:55 pm +0100 18.12.97, Anders Gardebring wrote:
>Is it possible to ask MacPerl to give 4 figures rather than two when Im asking
>for the year?

As far as I know, no.

>Now Im doing like this:
>
> @date = localtime;
>        $date[5] +=1900; # Add 1900 to the year....
>
>This is of course not so good when we pass year 2000....

Actually, it should work fine when we pass the year 2000. Perl isn't
*really* returning a two-figure year; it's returning the year - 1900 (see
page 185 in the Blue Camel). So in the year 2000, it will return 100, and
your solution will continue to work just fine. On the other hand, people
who write code that says:

	$date[5] = "19" + $date[5];

are going to lose big-time.

Admittedly, Perl's approach is not exactly the way I would have chosen to
implement a date system, but at least it isn't really locking you into a
two-digit year representation.

I believe that farmers have a maxim that says "Live as if you were going to
die tomorrow. Farm as if you were going to live forever." The analogous
maxim for our profession might be "Live as if you were going to die
tomorrow; write code as if you were going to have to maintain it forever."
Larry Wall stands a good chance of being alive on Jan 1st 2000, on which
date all the weenies who didn't read the Camel Book carefully enough will
see their systems go pear-shaped. And all I can say is, serves him right
when his mailbox fills with angry messages.

Of course, this raises the vexed question of what a sensible dating system
would be. Even if you allocate a sufficient number of digits to take us up
to, say, the year 999999 or so (it may be short-sighted of me, but I think
we can worry about the Y1M problem when the time comes), you still have to
choose the base date, the Year Zero. The supposed date of birth of
Yeshua-ben-Miriam is boring; *everybody* uses that. In the absence of a
better candidate, I suggest that we date things from the Hejira. If you're
still fixated on the Christian calendar, just add 622.

	Angus "After all, there are any number of
	       camels in the Koran, so it's almost
	       a Perl book in its own right." McIntyre

--
angus@pobox.com                                   http://pobox.com/~angus/

 "The Paris slums are a gathering place for             George Orwell
  eccentric people - people who have fallen           "Down and out in
  into solitary half-mad grooves of life, and          Paris and London"
  given up trying to be normal or decent."



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