{{- $w := .Params.weather -}} {{- if or (not $w) (eq (len $w) 0) -}} {{- return -}} {{- end -}} {{- $date := .Date -}} {{- $hour := (time $date).Hour -}} {{- $isNight := false -}} {{- if or (lt $hour 6) (ge $hour 18) -}} {{- $isNight = true -}} {{- end -}} {{- $precip := $w.precipitations -}} {{- $wind := $w.wind_speed -}} {{- $humidity := $w.humidity -}} {{- $illum := $w.illuminance -}} {{- $icon := "clear-day.svg" -}} {{- if $isNight -}} {{- $icon = "clear-night.svg" -}} {{- end -}} {{- if $precip -}} {{- $icon = "rain.svg" -}} {{- else if and $wind (ge $wind 45) -}} {{- $icon = "wind.svg" -}} {{- else if and $humidity (ge $humidity 90) (or (not $illum) (lt $illum 80)) -}} {{- $icon = "fog.svg" -}} {{- else if and $humidity (ge $humidity 75) -}} {{- if $isNight -}} {{- $icon = "partly-cloudy-night.svg" -}} {{- else -}} {{- $icon = "cloudy.svg" -}} {{- end -}} {{- end -}} {{- $label := "Météo" -}} {{- if eq $icon "clear-day.svg" -}}{{- $label = "Grand soleil" -}}{{- end -}} {{- if eq $icon "clear-night.svg" -}}{{- $label = "Ciel dégagé" -}}{{- end -}} {{- if eq $icon "partly-cloudy-day.svg" -}}{{- $label = "Partiellement nuageux" -}}{{- end -}} {{- if eq $icon "partly-cloudy-night.svg" -}}{{- $label = "Partiellement nuageux" -}}{{- end -}} {{- if eq $icon "cloudy.svg" -}}{{- $label = "Nuageux" -}}{{- end -}} {{- if eq $icon "drizzle.svg" -}}{{- $label = "Bruine" -}}{{- end -}} {{- if eq $icon "rain.svg" -}}{{- $label = "Pluvieux" -}}{{- end -}} {{- if eq $icon "snow.svg" -}}{{- $label = "Neige" -}}{{- end -}} {{- if eq $icon "thunderstorms-day.svg" -}}{{- $label = "Orage" -}}{{- end -}} {{- if eq $icon "fog.svg" -}}{{- $label = "Brouillard" -}}{{- end -}} {{- if eq $icon "wind.svg" -}}{{- $label = "Vent fort" -}}{{- end -}} {{- $sources := slice -}} {{- with $w.source -}} {{- if reflect.IsSlice . -}} {{- $sources = . -}} {{- else -}} {{- $sources = slice . -}} {{- end -}} {{- end -}}

Météo observée

{{ $label }} {{ printf "%s à %s" (time.Format "02/01/2006" $date) (time.Format ":time_short" $date) }}

{{- with $w.temperature -}}
Température
{{ printf "%.1f" (mul . 1.0) }} °C
{{- end -}} {{- with $w.humidity -}}
Humidité
{{ printf "%.0f" (mul . 1.0) }} %
{{- end -}} {{- with $w.pressure -}}
Pression
{{ printf "%.0f" (mul . 1.0) }} hPa
{{- end -}} {{- with $w.illuminance -}}
Luminosité
{{ printf "%.0f" (mul . 1.0) }} lx
{{- end -}} {{- with $w.wind_speed -}}
Vent
{{ printf "%.1f" (mul . 1.0) }} km/h
{{- end -}} {{- with $w.wind_direction -}}
Direction
{{ printf "%.0f" (mul . 1.0) }}°
{{- end -}}
{{- if gt (len $sources) 0 -}}

Sources: {{- range $i, $source := $sources -}} {{- if gt $i 0 -}}, {{- end -}}{{ $source }} {{- end -}}

{{- end -}}