home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!destroyer!sol.ctr.columbia.edu!ucselx!gdwest!good
- From: good@gdwest.gd.com (David L. Good)
- Subject: Re: bug in ctime.pl?
- Message-ID: <1992Jul22.234720.19969@gdwest.gd.com>
- Organization: General Dynamics Corp.
- References: <1992Jul21.201121.15732@nic.unh.edu>
- Date: Wed, 22 Jul 1992 23:47:20 GMT
- Lines: 31
-
- In article <1992Jul21.201121.15732@nic.unh.edu> pas@anchor.unh.edu (Paul A Sand) writes:
- >Based on some peculiar behavior, I looked at the ctime.pl library
- >file. It contains the line:
- >
- > $year += ($year < 70) ? 2000 : 1900;
- >
- >where $year is one of the elements returned from gmtime() or
- >localtime(). Looking at the definitions of what *those* return,
- >it seems the statement should be simply:
- >
- > $year += 1900;
- >
- >Or am I missing something subtle?
-
- Well, if as you state (and the man pages for both our Suns and HPs) the tm
- structure used in C uses years since 1900 for tm_year, the original line
- will still work. In fact, $year will _never_ be less than 70 (unless
- somebody sets their clock back for kicks or to be able to use time-bombed
- vendor software :-), so there's no problem. If, on the other hand, someone
- has a brain-dead UNIX (brain-dead, because there's no reason not to return
- "years since 1900" instead of "years since the beginning of the century"
- since there's plenty of room in even an 8-bit "int" for numbers greater
- than 99) that would return "0" for tm_year on Jan 1, 2000, the first line
- will _still_ work (at least for another 100 years :-).
-
- So...although it may seem a waste, ctime.pl is probably doing the right thing.
-
- --
- David Good good@gdwest.gd.com
-
- This space intentionally left blank.
-