@@ -111,6 +111,15 @@ Has no effect if `sparkweather-add-footer' is nil."
111111 :type 'boolean
112112 :group 'sparkweather )
113113
114+ (defcustom sparkweather-temperature-unit 'celsius
115+ " Temperature unit for display and API requests.
116+ Valid values are \\= 'celsius, \\= 'fahrenheit, \" C\" , or \" F\" ."
117+ :type '(choice (const :tag " Celsius" celsius)
118+ (const :tag " Fahrenheit" fahrenheit)
119+ (const :tag " C" " C" )
120+ (const :tag " F" " F" ))
121+ :group 'sparkweather )
122+
114123(defcustom sparkweather-lunch-start-hour 12
115124 " Start hour for lunch time window (24-hour format, 0-23).
116125
@@ -151,6 +160,20 @@ DEPRECATED: Use `sparkweather-time-windows' instead."
151160 'sparkweather-time-windows
152161 " 0.2.0" )
153162
163+ (defun sparkweather--temperature-unit-symbol ()
164+ " Return the display symbol (°C or °F) for the configured temperature unit."
165+ (pcase sparkweather-temperature-unit
166+ ((or 'fahrenheit " F" ) " °F" )
167+ (_ " °C" )))
168+
169+ (defun sparkweather--convert-temperature (celsius )
170+ " Convert CELSIUS temperature to the configured unit.
171+ Returns temperature in Fahrenheit if unit is set to fahrenheit or \" F\" ,
172+ otherwise returns CELSIUS unchanged."
173+ (pcase sparkweather-temperature-unit
174+ ((or 'fahrenheit " F" ) (+ (* celsius 1.8 ) 32 ))
175+ (_ celsius)))
176+
154177(defun sparkweather--detect-invalid-windows (windows )
155178 " Detect windows with invalid hour ranges in WINDOWS list.
156179Returns list of invalid windows as (NAME START END REASON), or nil if all valid.
@@ -548,15 +571,19 @@ Returns (temps precip-probs temp-min temp-max precip-max rainy-codes)."
548571Returns list of entries for `tabulated-list-mode' ."
549572 (pcase-let* ((`(, temps , precip-probs , temp-min , temp-max , precip-max , rainy-codes )
550573 (sparkweather--calculate-ranges data))
574+ (converted-temps (mapcar #'sparkweather--convert-temperature temps))
551575 (`(, window-data , highlights )
552576 (sparkweather--prepare-windows data windows))
553- (temp-sparkline (sparkweather--sparkline temps highlights current-hour))
577+ (temp-sparkline (sparkweather--sparkline converted- temps highlights current-hour))
554578 (precip-sparkline (sparkweather--sparkline precip-probs highlights current-hour))
555579 (worst-weather-code (and rainy-codes (apply #'max rainy-codes)))
556580 (worst-weather-info (when worst-weather-code
557581 (sparkweather--wmo-code-info worst-weather-code))))
558582 (append
559- (list (list 'temp (vector (format " %d —%d °C" (round temp-min) (round temp-max))
583+ (list (list 'temp (vector (format " %d —%d%s "
584+ (round (sparkweather--convert-temperature temp-min))
585+ (round (sparkweather--convert-temperature temp-max))
586+ (sparkweather--temperature-unit-symbol))
560587 temp-sparkline)))
561588 (when worst-weather-info
562589 (list (list 'precip (vector (format " %d%% %s "
0 commit comments