Bug: Sunrise/Sunset shows incorrect time in 24-hours
Closed this issue · 3 comments
how often do you face this issue?
Also sunset, sunrise and and time in the graph are converted to local time of the selected location, can you also confirm about this?
Hey, I have the same issue (screenshot attached), just adding some system information so it might be easier to debug this issue.
I think I might have found the issue though: for other cards (like the hourly weather/wind/etc.) the program checks whether to use the 24 hour time format and uses the right formatting accordingly (see frontendHourlyDetails.py#L198). For the sunrise/sunset card it doesn't do that, it just uses "%I:%M %p"
which according to strftime.org is the 12 hour time format (frontendCardDayNight.py#L45).
A possible fix might be to add/change the following code in frontendCardDayNight.py
:
- sunrise = datetime.fromtimestamp(sunrise_ts - time_diff).strftime("%I:%M %p")
- sunset = datetime.fromtimestamp(sunset_ts - time_diff).strftime("%I:%M %p")
+ sunrise_timestamp = datetime.fromtimestamp(sunrise_ts - time_diff)
+ sunset_timestamp = datetime.fromtimestamp(sunset_ts - time_diff)
+ sunrise = sunrise_timestamp.strftime("%I:%M %p")
+ sunset = sunset_timestamp.strftime("%I:%M %p")
+ if settings.is_using_24h_clock:
+ sunrise = sunrise_timestamp.strftime("%H:%M")
+ sunset = sunset_timestamp.strftime("%H:%M")
I might open a PR with this fix later, I don't have time to do it right now...
Mousam settings
- dynamic background: on
- Time Format: 24 Hour
- Units & Measurements: metric
locale
$ locale
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=
(de_DE
uses the 24 hour time format)
timedatectl
$ timedatectl status
Local time: Sa 2024-06-15 13:15:17 CEST
Universal time: Sa 2024-06-15 11:15:17 UTC
RTC time: Sa 2024-06-15 11:15:17
Time zone: Europe/Berlin (CEST, +0200)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
System Info:
OS: Arch Linux
Kernel: 6.9.3-arch1-1
DE: Plasma 6.0.5
Exactly, you got it right, thanks for looking into the issue 🙂.
Definitely you can raise the pr with this.