Skip to content
Browse files

Mode-line: take last time if it is not in range.

Temperature, cloudiness, etc. are only given for fixed hours. So take
the last time!

Signed-off-by: Rüdiger Sonderfeld <>
  • Loading branch information...
1 parent d521943 commit d6d6d3066112228e16e489c6271e10af95464289 @ruediger committed Oct 4, 2012
Showing with 16 additions and 3 deletions.
  1. +16 −3 weather-metno-mode-line.el
19 weather-metno-mode-line.el
@@ -63,15 +63,16 @@ Values are expected in `decode-time' format."
(time (decode-time))
(temperature most-negative-fixnum)
(cloudiness most-negative-fixnum)
- (precipitation most-negative-fixnum))
+ (precipitation most-negative-fixnum)
+ (last-time '(0 0 0 0 0 0)))
(dolist (forecast (cadr location))
(let* ((date-range (car forecast))
(from (car date-range))
(from-time (decode-time from))
(to (cadr date-range))
(to-time (decode-time to)))
- (when (weather-metno-mode-line~time-in-range? time from-time to-time)
+ (if (weather-metno-mode-line~time-in-range? time from-time to-time)
(dolist (entry (cdr forecast))
(case (car entry)
(temperature (let ((value (string-to-number
@@ -85,7 +86,19 @@ Values are expected in `decode-time' format."
(precipitation (let ((value (string-to-number
(cdr (assq 'value (cadr entry))))))
(when (< precipitation value)
- (setq precipitation value)))))))))
+ (setq precipitation value))))))
+ (when (and (weather-metno-mode-line~date<= from-time time)
+ (weather-metno-mode-line~date<= last-time from-time))
+ (setq last-time from-time)
+ (dolist (entry (cdr forecast))
+ (case (car entry)
+ (temperature (setq temperature (string-to-number
+ (cdr (assq 'value (cadr entry))))))
+ (cloudiness (setq cloudiness (string-to-number
+ (cdr (assq 'percent (cadr entry))))))
+ (precipitation (setq precipitation (string-to-number
+ (cdr (assq 'value (cadr entry))))))))))))
+ (message "%s" last-time)
(format "[%s℃ %s㎜ %s%%]"
(if (= temperature most-negative-fixnum)
"X" temperature)

0 comments on commit d6d6d30

Please sign in to comment.
Something went wrong with that request. Please try again.