Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 <ruediger@c-plusplus.de>
  • Loading branch information...
commit d6d6d3066112228e16e489c6271e10af95464289 1 parent d521943
Rüdiger Sonderfeld authored

Showing 1 changed file with 16 additions and 3 deletions. Show diff stats Hide diff stats

  1. +16 3 weather-metno-mode-line.el
19 weather-metno-mode-line.el
@@ -63,7 +63,8 @@ Values are expected in `decode-time' format."
63 63 (time (decode-time))
64 64 (temperature most-negative-fixnum)
65 65 (cloudiness most-negative-fixnum)
66   - (precipitation most-negative-fixnum))
  66 + (precipitation most-negative-fixnum)
  67 + (last-time '(0 0 0 0 0 0)))
67 68
68 69 (dolist (forecast (cadr location))
69 70 (let* ((date-range (car forecast))
@@ -71,7 +72,7 @@ Values are expected in `decode-time' format."
71 72 (from-time (decode-time from))
72 73 (to (cadr date-range))
73 74 (to-time (decode-time to)))
74   - (when (weather-metno-mode-line~time-in-range? time from-time to-time)
  75 + (if (weather-metno-mode-line~time-in-range? time from-time to-time)
75 76 (dolist (entry (cdr forecast))
76 77 (case (car entry)
77 78 (temperature (let ((value (string-to-number
@@ -85,7 +86,19 @@ Values are expected in `decode-time' format."
85 86 (precipitation (let ((value (string-to-number
86 87 (cdr (assq 'value (cadr entry))))))
87 88 (when (< precipitation value)
88   - (setq precipitation value)))))))))
  89 + (setq precipitation value))))))
  90 + (when (and (weather-metno-mode-line~date<= from-time time)
  91 + (weather-metno-mode-line~date<= last-time from-time))
  92 + (setq last-time from-time)
  93 + (dolist (entry (cdr forecast))
  94 + (case (car entry)
  95 + (temperature (setq temperature (string-to-number
  96 + (cdr (assq 'value (cadr entry))))))
  97 + (cloudiness (setq cloudiness (string-to-number
  98 + (cdr (assq 'percent (cadr entry))))))
  99 + (precipitation (setq precipitation (string-to-number
  100 + (cdr (assq 'value (cadr entry))))))))))))
  101 + (message "%s" last-time)
89 102 (format "[%s℃ %s㎜ %s%%]"
90 103 (if (= temperature most-negative-fixnum)
91 104 "X" temperature)

0 comments on commit d6d6d30

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