From 52bc35e1956391dd3b08ecbedd022da25e746c9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aur=C3=A9lio=20A=2E=20Heckert=20=28a=29?= Date: Wed, 3 Nov 2010 00:06:36 -0300 Subject: [PATCH] Resolves the year 1 problem on the calendar render extension. It includes the patch code by Craig Marshall, posted on bug492173 This commit changes the default inx year value and its description to stop misunderstands about how it works. --- share/extensions/svgcalendar.inx | 4 ++-- share/extensions/svgcalendar.py | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/share/extensions/svgcalendar.inx b/share/extensions/svgcalendar.inx index dee9da0c6..56f5f62ab 100644 --- a/share/extensions/svgcalendar.inx +++ b/share/extensions/svgcalendar.inx @@ -6,8 +6,8 @@ inkex.py + 2011 0 - 0 true <_item value="sun">Sunday @@ -125,7 +125,7 @@ <_param name="encoding-help" type="description">Select your system encoding. More information at http://docs.python.org/library/codecs.html#standard-encodings. - + all diff --git a/share/extensions/svgcalendar.py b/share/extensions/svgcalendar.py index b62863927..8390c33f7 100755 --- a/share/extensions/svgcalendar.py +++ b/share/extensions/svgcalendar.py @@ -131,6 +131,8 @@ class SVGCalendar (inkex.Effect): self.options.day_names = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] # Convert year 0 to current year: if self.options.year == 0: self.options.year = datetime.today().year + # Year 1 starts it's week at monday, obligatorily + if self.options.year == 1: self.options.start_day = 'mon' # Set the calendar start day: if self.options.start_day=='sun': calendar.setfirstweekday(6) @@ -266,8 +268,9 @@ class SVGCalendar (inkex.Effect): gdays = inkex.etree.SubElement(g, 'g') cal = calendar.monthcalendar(self.options.year,m) if m == 1: - before_month = \ - self.in_line_month( calendar.monthcalendar(self.options.year-1, 12) ) + if self.options.year > 1: + before_month = \ + self.in_line_month( calendar.monthcalendar(self.options.year-1, 12) ) else: before_month = \ self.in_line_month( calendar.monthcalendar(self.options.year, m-1) ) @@ -297,8 +300,8 @@ class SVGCalendar (inkex.Effect): 'x': str( self.day_w * week_x ), 'y': str( self.day_h * (week_y+2) ) } if day==0 and not self.options.fill_edb: - pass # draw nothing - elif day==0: + pass # draw nothing + elif day==0: if before: inkex.etree.SubElement(gdays, 'text', txt_atts).text = str( before_month[-bmd] ) bmd -= 1 -- 2.30.2