From ef07e51371773c9cfb61aa6e63e3c3e904e293ff Mon Sep 17 00:00:00 2001 From: Vitali Samurov Date: Mon, 17 Aug 2020 21:54:53 +0300 Subject: [PATCH 1/2] Fix for 7 rows in Calendar, when the month starts from Sat --- inkycal/modules/inkycal_calendar.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/inkycal/modules/inkycal_calendar.py b/inkycal/modules/inkycal_calendar.py index 56b288c..1bbcd8e 100644 --- a/inkycal/modules/inkycal_calendar.py +++ b/inkycal/modules/inkycal_calendar.py @@ -80,7 +80,14 @@ class Calendar(inkycal_module): im_width, calendar_height)) # Create grid and calculate icon sizes - calendar_rows, calendar_cols = 6, 7 + now = arrow.now(tz = self.timezone) + monthstart = now.span('month')[0].weekday() + + if (monthstart > 4): + calendar_rows, calendar_cols = 7, 7 + else: + calendar_rows, calendar_cols = 6, 7 + icon_width = im_width // calendar_cols icon_height = calendar_height // calendar_rows @@ -98,8 +105,6 @@ class Calendar(inkycal_module): weekday_pos = [(grid_start_x + icon_width*_, month_name_height) for _ in range(calendar_cols)] - now = arrow.now(tz = self.timezone) - # Set weekstart of calendar to specified weekstart if self.weekstart == "Monday": cal.setfirstweekday(cal.MONDAY) From 3f727ecf08fa9cf94ed7740946ae70e1c61a51e2 Mon Sep 17 00:00:00 2001 From: Vitali Samurov Date: Mon, 17 Aug 2020 22:58:01 +0300 Subject: [PATCH 2/2] Number of days in month added --- inkycal/modules/inkycal_calendar.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inkycal/modules/inkycal_calendar.py b/inkycal/modules/inkycal_calendar.py index 1bbcd8e..6e3ad5d 100644 --- a/inkycal/modules/inkycal_calendar.py +++ b/inkycal/modules/inkycal_calendar.py @@ -82,8 +82,9 @@ class Calendar(inkycal_module): # Create grid and calculate icon sizes now = arrow.now(tz = self.timezone) monthstart = now.span('month')[0].weekday() + monthdays = now.ceil('month').day - if (monthstart > 4): + if monthstart > 4 and monthdays == 31: calendar_rows, calendar_cols = 7, 7 else: calendar_rows, calendar_cols = 6, 7