[Zope] a patch for the calendar tag 0.9.10

Jerome ALET Jerome.Alet@unice.fr
Sun, 4 Jun 2000 13:25:04 +0200


--7JfCtLOvnd9MIVvH
Content-Type: text/plain; charset=us-ascii

Sorry, I've created a new patch, because in my previous one I've
forgotten to correct the day mode too.

The problem happens in day mode as well as in week mode, even
if the week wasn't between two months.

Sorry for the incoveninence, you'll find the new patch attached 
to this message.

bye,
Jerome Alet

On Sun, Jun 04, 2000 at 11:20:34AM +0200, Jerome ALET wrote:
> here's a patch for the Calendar 0.9.10 product.
> ...
> The Calendar product doesn't cut the month names
> correctly in regard to these entities, especially
> in week mode when a week was between two months.

--7JfCtLOvnd9MIVvH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Calendar-0.9.10.patch2"

--- CalendarTag.py.orig	Sun Jun  4 11:09:54 2000
+++ CalendarTag.py	Sun Jun  4 13:18:40 2000
@@ -114,6 +114,22 @@
         self.week_sday = int(weekdays[0])
         self.week_ndays = int(weekdays[1])
 
+    def __cutmonthname(self, name, length) :
+        """Cuts the month name at length characters, counting
+        character entities for only one character"""
+        entityfound = 0
+        for i in range(len(name)) :
+                if name[i] == '&' :
+                        entityfound = 1
+                elif name[i] == ';' :         
+                        entityfound = 0
+        
+                if not entityfound :
+                        length = length - 1
+                        if not length :
+                                break
+        return name[:i + 1]    
+                        
     def render(self, md):
 ##        time_start = time()
 
@@ -226,15 +242,15 @@
             v['next_url_'] = self.linkDate_(d, mode)
         else:
             if self.mode == 'day':
-                monthname = v['monthnames'][date.month() - 1][:3]
+                monthname = self.__cutmonthname(v['monthnames'][date.month() - 1], 3)
                 left = '%s %d, %d' % (monthname, date.day(), date.year())
                 v['day_img_'] = 'sday'
                 v['daynames'] = None
             elif self.mode == 'week':
                 sdow = date - date.dow()
                 edow = sdow + 6
-                smonthname = v['monthnames'][sdow.month() - 1][:3]
-                emonthname = v['monthnames'][edow.month() - 1][:3]
+                smonthname = self.__cutmonthname(v['monthnames'][sdow.month() - 1], 3)
+                emonthname = self.__cutmonthname(v['monthnames'][edow.month() - 1], 3)
 
                 left = '%s %d' % (emonthname, edow.year())
                 if sdow.aMonth() != edow.aMonth():

--7JfCtLOvnd9MIVvH--