home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7689 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  2.0 KB

  1. Path: sparky!uunet!mcsun!uknet!cardamom.compnews.co.uk!phil
  2. From: phil@compnews.co.uk (Phil Male)
  3. Newsgroups: comp.lang.perl
  4. Subject: Bug in timelocal
  5. Summary: timelocal $tzmin incorrect
  6. Message-ID: <1ifbnpINN8hl@cardamom.compnews.co.uk>
  7. Date: 6 Jan 93 19:25:45 GMT
  8. Reply-To: phil@compnews.co.uk
  9. Organization: Computer Newspaper Services, Howden, UK.
  10. Lines: 55
  11. NNTP-Posting-Host: sage.compnews.co.uk
  12. X-Newsreader: Tin 1.1 PL4
  13.  
  14. I'm either doing something very stupid here or there is a bug in the timelocal
  15. package.
  16.  
  17. From Perl 4.035 lib/timelocal.pl:
  18.  
  19. CONFIG: {
  20.     package timelocal;
  21.  
  22.     local($[) = 0;
  23.     @epoch = localtime(0);
  24.     $tzmin = $epoch[2] * 60 + $epoch[1];       # minutes east of GMT
  25.     if ($tzmin > 0) {
  26.        $tzmin = 24 * 60 - $tzmin;              # minutes west of GMT
  27.        $tzmin -= 24 * 60 if $epoch[5] == 70;   # account for the date line
  28.     }
  29.  
  30.     $SEC = 1;
  31.     $MIN = 60 * $SEC;
  32.     $HR = 60 * $MIN;
  33.     $DAYS = 24 * $HR;
  34. }
  35.  
  36. This code makes the assumption that the clock offset at localtime(0) is
  37. equal to the clock offset when $isdst is 0.
  38.  
  39. from /usr/lib/zoneinfo/europe:
  40.  
  41. #       1967    March 19        October 29
  42. #       1968    February 18     October 27
  43. # "British Standard Time, also one hour ahead of G. M. T., was kept between
  44. # 1968 Oct. 27-1971 Oct. 31."
  45. #       1972    March 19        October 29
  46.  
  47. ..which just happens to be around the epoch.
  48.  
  49. Now, the point is that at the epoch, according to our Suns and several other
  50. boxes, time in GB-Eire was one hour ahead of GMT, but DST was not in effect.
  51. (This could be a bug in the europe definition file of course...)
  52.  
  53. The problem gets worse because...
  54.  
  55.     $time -= $HR if $test[2] != $_[2];
  56.  
  57. in timelocal() takes another hour off.
  58.  
  59. Am I being very stupid, I can't believe that no-one has not spotted this
  60. before...
  61.  
  62. --
  63.  
  64. phil 
  65.    ___/   /
  66.    /_/)  /             Phil Male, Director, Information Systems
  67.   / /_ '/  Computer Newspaper Services, The Bishops Manor, Howden, DN14 7BL
  68.  / / ///    +44 43043 Tel: 1100 Fax: 1108/2022  email: phil@compnews.co.uk
  69.