home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!nic.unh.edu!kepler.unh.edu!pas
- From: pas@kepler.unh.edu (Paul A Sand)
- Subject: Re: bug in ctime.pl?
- Message-ID: <1992Jul22.034307.28386@nic.unh.edu>
- Sender: news@nic.unh.edu (USENET News System)
- Organization: University of New Hampshire
- References: <1992Jul21.201121.15732@nic.unh.edu> <CKD.92Jul21220835@loiosh.eff.org>
- Date: Wed, 22 Jul 1992 03:43:07 GMT
- Lines: 34
-
- In article <CKD.92Jul21220835@loiosh.eff.org> ckd@eff.org (Christopher Davis) writes:
- >Paul> == Paul A Sand <pas@anchor.unh.edu>
- >
- > Paul> Based on some peculiar behavior, I looked at the ctime.pl library
- > Paul> file. It contains the line:
- >
- > Paul> $year += ($year < 70) ? 2000 : 1900;
- >
- > Paul> where $year is one of the elements returned from gmtime() or
- > Paul> localtime(). Looking at the definitions of what *those* return,
- > Paul> it seems the statement should be simply:
- >
- > Paul> $year += 1900;
- >
- > Paul> Or am I missing something subtle?
-
- >The subtle thing you're missing will become clear in about 8 years, when
- >your modified version tells you that it's 1900. This is okay if you're
- >writing a real-time Diplomacy game program, but kinda sucks for use in
- >other applications, if you know what I mean.
-
- >The magic number 70 is from the Unix epoch of Jan 1, 1970.
-
- That's not subtle enough :-). The references I've checked with regard
- to the ANSI C functions gmtime() and localtime() claim that the
- `tm_year' member of their 'struct tm' return value is simply 'years
- since 1900', and don't say anything about 'modulo 100' or any special
- handling for good old 1970 and before, or 2000 and after, for that
- matter. This could be different in Perl, but the Camel book seems to
- claim that it's not.
- --
- -- 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.)
-