🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.gnus
Article #584

gnus 3.14.1 mishandles timezones that are not on hour boundaries

#584
From: Paul Eggert
Date: Tue, 05 Jan 1993 05:33
106 lines
4319 bytes
GNUS 3.14.1 assumes that time zones differ from GMT by an integral number of
hours.  This doesn't work for India, which is GMT +0530.  Here's a patch.


===================================================================
RCS file: timezone.el,v
retrieving revision 3.14.1.1
retrieving revision 3.14.1.2
diff -c -r3.14.1.1 -r3.14.1.2
*** timezone.el	1993/01/04 22:49:05	3.14.1.1
--- timezone.el	1993/01/04 23:38:51	3.14.1.2
***************
*** 66,75 ****
  	 (second (string-to-int (aref time 2)))
  	 (local  (or (aref date 4) local)) ;Use original if defined
  	 (timezone (or timezone local))
! 	 (diff   (- (timezone-zone-to-hour timezone)
! 		    (timezone-zone-to-hour local)))
  	 (new    (timezone-fix-time year month day
! 				    (+ hour diff) minute second)))
      (timezone-make-arpa-date (aref new 0) (aref new 1) (aref new 2)
  			     (timezone-make-time-string
  			      (aref new 3) (aref new 4) (aref new 5))
--- 66,75 ----
  	 (second (string-to-int (aref time 2)))
  	 (local  (or (aref date 4) local)) ;Use original if defined
  	 (timezone (or timezone local))
! 	 (diff   (- (timezone-zone-to-minute timezone)
! 		    (timezone-zone-to-minute local)))
  	 (new    (timezone-fix-time year month day
! 				    hour (+ minute diff) second)))
      (timezone-make-arpa-date (aref new 0) (aref new 1) (aref new 2)
  			     (timezone-make-time-string
  			      (aref new 3) (aref new 4) (aref new 5))
***************
*** 90,99 ****
  	 (second (string-to-int (aref time 2)))
  	 (local  (or (aref date 4) local)) ;Use original if defined
  	 (timezone (or timezone local))
! 	 (diff   (- (timezone-zone-to-hour timezone)
! 		    (timezone-zone-to-hour local)))
  	 (new    (timezone-fix-time year month day
! 				    (+ hour diff) minute second)))
      (timezone-make-sortable-date (aref new 0) (aref new 1) (aref new 2)
  				 (timezone-make-time-string
  				  (aref new 3) (aref new 4) (aref new 5)))
--- 90,99 ----
  	 (second (string-to-int (aref time 2)))
  	 (local  (or (aref date 4) local)) ;Use original if defined
  	 (timezone (or timezone local))
! 	 (diff   (- (timezone-zone-to-minute timezone)
! 		    (timezone-zone-to-minute local)))
  	 (new    (timezone-fix-time year month day
! 				    hour (+ minute diff) second)))
      (timezone-make-sortable-date (aref new 0) (aref new 1) (aref new 2)
  				 (timezone-make-time-string
  				  (aref new 3) (aref new 4) (aref new 5)))
***************
*** 210,217 ****
  
  ;; Miscellaneous
  
! (defun timezone-zone-to-hour (timezone)
!   "Translate TIMEZONE (in zone name or integer) to integer hour."
    (if timezone
        (progn
  	(setq timezone
--- 210,217 ----
  
  ;; Miscellaneous
  
! (defun timezone-zone-to-minute (timezone)
!   "Translate TIMEZONE (in zone name or integer) to integer minute."
    (if timezone
        (progn
  	(setq timezone
***************
*** 220,230 ****
  		  timezone))
  	(if (stringp timezone)
  	    (setq timezone (string-to-int timezone)))
! 	(/ timezone 100))
      0))
  
  (defun timezone-fix-time (year month day hour minute second)
    "Fix date and time."
    (cond ((<= 24 hour)			;24 -> 00
  	 (setq hour (- hour 24))
  	 (setq day  (1+ day))
--- 220,235 ----
  		  timezone))
  	(if (stringp timezone)
  	    (setq timezone (string-to-int timezone)))
! 	(let* ((abszone (max timezone (- timezone)))
! 	       (minutes (+ (* 60 (/ abszone 100)) (% abszone 100))))
! 	  (if (< timezone 0) (- minutes) minutes)))
      0))
  
  (defun timezone-fix-time (year month day hour minute second)
    "Fix date and time."
+   (let ((hourfix (if (< minute 0) (- (/ (- 59 minute) 60)) (/ minute 60))))
+     (setq hour (+ hour hourfix))
+     (setq minute (- minute (* 60 hourfix))))
    (cond ((<= 24 hour)			;24 -> 00
  	 (setq hour (- hour 24))
  	 (setq day  (1+ day))
Technical Details
Message-ID: <9301050533.AA10437@farside.twinsun.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert

Show Full Headers
Complete Article Headers
Newsgroups: gnu.emacs.gnus
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert
From: eggert@twinsun.COM (Paul Eggert)
Subject: gnus 3.14.1 mishandles timezones that are not on hour boundaries
Message-ID: <9301050533.AA10437@farside.twinsun.com>
Sender: daemon@cis.ohio-state.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 5 Jan 1993 05:33:24 GMT
Lines: 106