[Zope] Bug in dtml-calendar 1.0.12 (Stable)
Harold Lutenbacher
harold@lilac.ocn.ne.jp
Sun, 03 Mar 2002 12:21:37 +0900
At 08:20 PM 3/2/02 +0200, you wrote:
>I just noticed that dtml-calendar tag shows calendar wrong
>, if you set set weekdays to 15 in month mode. What it is supposed to
>do, is draw the calendar with only the weekdays present -- which it
>actually does -- but it just jumps over weekends. Meaning today is 2 nd
>of March saturday, but the calendar shows it as a monday.
>
><dtml-calendar controls=no modes="month" bgcolor="#DDDDDD" lang=fi
>weekdays="15" tablewidth=200>
>...
></dtml-calendar>
Hi,
I think if you open the calendar tag source in the products directory, go
to line 946 in the render_dwm function and add the following line, it will
give you what you want.
Original code:
d = bd
month = bd.month()
while d.month() == month:
if c == self.week_ndays:
s = s + '</tr><tr>'
c = 0
s = s + self.render_day_(md, d, d == bd)
d = d + 1
c = c + 1
if c < self.week_ndays:
s = s + '<td bgcolor="%s" colspan="%s"> </td>' % (
self.bgcolor, self.week_ndays - c)
s = s + '</tr>'
After change:
d = bd
month = bd.month()
while d.month() == month:
if c == self.week_ndays:
s = s + '</tr><tr>'
c = 0
Add this line ===> d = d + 2
s = s + self.render_day_(md, d, d == bd)
d = d + 1
c = c + 1
if c < self.week_ndays:
s = s + '<td bgcolor="%s" colspan="%s"> </td>' % (
self.bgcolor, self.week_ndays - c)
s = s + '</tr>'
It looks like the original code wasn't incrementing the date to account for
the skipped days. NOTE: This will only work for weekdays="15". You need
to set up a variable that is subtracted from 7 to handle other weekdays
parameters. I haven't figured that out yet!
Harold Lutenbacher
harold@lilac.ocn.ne.jp