home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 4860 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.9 KB  |  46 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!nic.unh.edu!kepler.unh.edu!pas
  3. From: pas@kepler.unh.edu (Paul A Sand)
  4. Subject: Re: bug in ctime.pl?
  5. Message-ID: <1992Jul22.034307.28386@nic.unh.edu>
  6. Sender: news@nic.unh.edu (USENET News System)
  7. Organization: University of New Hampshire
  8. References: <1992Jul21.201121.15732@nic.unh.edu> <CKD.92Jul21220835@loiosh.eff.org>
  9. Date: Wed, 22 Jul 1992 03:43:07 GMT
  10. Lines: 34
  11.  
  12. In article <CKD.92Jul21220835@loiosh.eff.org> ckd@eff.org (Christopher Davis) writes:
  13. >Paul> == Paul A Sand <pas@anchor.unh.edu> 
  14. >
  15. > Paul> Based on some peculiar behavior, I looked at the ctime.pl library
  16. > Paul> file. It contains the line:
  17. >
  18. > Paul>      $year += ($year < 70) ? 2000 : 1900;
  19. >
  20. > Paul> where $year is one of the elements returned from gmtime() or
  21. > Paul> localtime(). Looking at the definitions of what *those* return,
  22. > Paul> it seems the statement should be simply:
  23. >
  24. > Paul>     $year += 1900;
  25. >
  26. > Paul> Or am I missing something subtle?
  27.  
  28. >The subtle thing you're missing will become clear in about 8 years, when
  29. >your modified version tells you that it's 1900.  This is okay if you're
  30. >writing a real-time Diplomacy game program, but kinda sucks for use in
  31. >other applications, if you know what I mean.
  32.  
  33. >The magic number 70 is from the Unix epoch of Jan 1, 1970.
  34.  
  35. That's not subtle enough :-). The references I've checked with regard
  36. to the ANSI C functions gmtime() and localtime() claim that the
  37. `tm_year' member of their 'struct tm' return value is simply 'years
  38. since 1900', and don't say anything about 'modulo 100' or any special
  39. handling for good old 1970 and before, or 2000 and after, for that
  40. matter. This could be different in Perl, but the Camel book seems to
  41. claim that it's not.
  42. -- 
  43. -- Paul A. Sand           | I learned to put the [toilet] seat down...it
  44. -- Univ. of New Hampshire | makes you look like a warm, caring, sensitive
  45. -- pas@kepler.unh.edu     | human being. (Prof. R. Noble, from r.h.f.)
  46.