home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!nic.unh.edu!anchor.unh.edu!pas
- From: pas@anchor.unh.edu (Paul A Sand)
- Subject: Re: bug in ctime.pl?
- Message-ID: <1992Jul22.130507.12141@nic.unh.edu>
- Sender: news@nic.unh.edu (USENET News System)
- Organization: University of New Hampshire
- References: <1992Jul21.201121.15732@nic.unh.edu> <BrryKL.Msx@rahul.net>
- Date: Wed, 22 Jul 1992 13:05:07 GMT
- Lines: 49
-
- In article <BrryKL.Msx@rahul.net> dhesi@rahul.net (Rahul Dhesi) writes:
- >In <1992Jul21.201121.15732@nic.unh.edu> pas@anchor.unh.edu (Paul A Sand)
- >wonders if ctime.pl should do $year += 1900 instead of
- >
- >> $year += ($year < 70) ? 2000 : 1900;
- >
- >Both are identical at this time. However, some time in the next
- >century, when the 32-bit value of Unix time overflows and time begins
- >running backwards, the two will give different results. Whichever form
- >gives a value closer to the truth will then be preferable; I believe
- >the longer form will be the one.
-
- Looking at the code in ctime.pl, I think you are (in effect) claiming
- that the Perl gmtime()/localtime() functions are broken, or will break
- sometime next century. (More specifically: they will start returning
- the wrong value for the 'years since 1900' element of their return
- values. As far as I can tell, that's what they are supposed to do.) I
- haven't tested that, but I don't think that's standard behavior for the
- analogous C functions.
-
- Perhaps I should have been more specific about what I regarded
- as peculiar. Here in lovely New Hampshire, this C program:
-
- #include <time.h>
- main()
- {
- time_t t;
- t = 0;
- printf("%s", ctime(&t));
- }
-
- prints:
-
- Wed Dec 31 19:00:00 1969
-
- (i.e., midnight in Greenwich) But this:
-
- % perl -e 'require "ctime.pl"; print &ctime(0);'
-
- prints:
-
- Wed Dec 31 19:00:00 2069
-
- I think my proposed change would (at least) make the Perl and C
- versions of ctime() behave alike.
- --
- -- Paul A. Sand | I learned to put the [toilet] seat down...it
- -- Univ. of New Hampshire | makes you look like a warm, caring, sensitive
- -- pas@kepler.unh.edu | human being. (Prof. R. Noble, from r.h.f.)
-