comparison lisp/timezone.el @ 4510:10baf5e7550f

(timezone-fix-time, timezone-zone-to-minute): Simplify with `abs' and `floor' functions instead of doing it ourselves.
author Paul Eggert <eggert@twinsun.com>
date Tue, 10 Aug 1993 04:14:17 +0000
parents 1489eda1a90b
children 4324c797a9e3
comparison
equal deleted inserted replaced
4509:aeef9d07f78d 4510:10baf5e7550f
231 timezone)) 231 timezone))
232 (if (stringp timezone) 232 (if (stringp timezone)
233 (setq timezone (string-to-int timezone))) 233 (setq timezone (string-to-int timezone)))
234 ;; Taking account of minute in timezone. 234 ;; Taking account of minute in timezone.
235 ;; HHMM -> MM 235 ;; HHMM -> MM
236 ;;(+ (* 60 (/ timezone 100)) (% timezone 100)) 236 (let* ((abszone (abs timezone))
237 ;; ANSI C compliance about truncation of integer division
238 ;; by eggert@twinsun.com (Paul Eggert)
239 (let* ((abszone (max timezone (- timezone)))
240 (minutes (+ (* 60 (/ abszone 100)) (% abszone 100)))) 237 (minutes (+ (* 60 (/ abszone 100)) (% abszone 100))))
241 (if (< timezone 0) (- minutes) minutes)))) 238 (if (< timezone 0) (- minutes) minutes))))
242 (t 0))) 239 (t 0)))
243 240
244 (defun timezone-time-from-absolute (date seconds) 241 (defun timezone-time-from-absolute (date seconds)
291 (timezone-absolute-from-gregorian month day year) 288 (timezone-absolute-from-gregorian month day year)
292 (+ second (* 60 (+ minute (* 60 hour))))))) 289 (+ second (* 60 (+ minute (* 60 hour)))))))
293 (diff (- (timezone-zone-to-minute timezone) 290 (diff (- (timezone-zone-to-minute timezone)
294 (timezone-zone-to-minute local))) 291 (timezone-zone-to-minute local)))
295 (minute (+ minute diff)) 292 (minute (+ minute diff))
296 (hour-fix 293 (hour-fix (floor minute 60)))
297 (if (< minute 0)
298 ;;(/ (- minute 59) 60) (/ minute 60)
299 ;; ANSI C compliance about truncation of integer division
300 ;; by eggert@twinsun.com (Paul Eggert)
301 (- (/ (- 59 minute) 60)) (/ minute 60))))
302 (setq hour (+ hour hour-fix)) 294 (setq hour (+ hour hour-fix))
303 (setq minute (- minute (* 60 hour-fix))) 295 (setq minute (- minute (* 60 hour-fix)))
304 ;; HOUR may be larger than 24 or smaller than 0. 296 ;; HOUR may be larger than 24 or smaller than 0.
305 (cond ((<= 24 hour) ;24 -> 00 297 (cond ((<= 24 hour) ;24 -> 00
306 (setq hour (- hour 24)) 298 (setq hour (- hour 24))