Skip to content

Commit

Permalink
fix(clock): ensure selected day does not exceed days in month
Browse files Browse the repository at this point in the history
  • Loading branch information
amnweb committed Feb 9, 2025
1 parent ed26165 commit a9f0916
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core/widgets/yasb/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,13 @@ def update_month_label(self, year, month):
qlocale = QLocale(self._locale) if self._locale else QLocale.system()
new_month = qlocale.monthName(month)
self.month_label.setText(new_month)
# Update day and date based on the calendar’s selected day
selectedDate = self.calendar.selectedDate()
newDate = QDate(year, month, selectedDate.day())

selected_day = self.calendar.selectedDate().day()
days_in_month = QDate(year, month, 1).daysInMonth()
if selected_day > days_in_month:
selected_day = days_in_month

newDate = QDate(year, month, selected_day)
self.day_label.setText(qlocale.dayName(newDate.dayOfWeek()))
self.date_label.setText(newDate.toString("d"))

Expand Down

0 comments on commit a9f0916

Please # to comment.