[Zope-CMF] CMFCalender and monthRange Probs

Andrew Sawyers andrew@zope.com
Thu, 23 Aug 2001 09:27:38 -0400


You don't have all the code for the monthRange.py:

from DateTime import DateTime

  def monthRange( dt ):
      """
      Return a pair of DateTime values representing the
      earliest and latest times in the month in which 'dt'
      falls.
      """
      y, m, d = dt.year(), dt.month(), dt.day()
      first = DateTime( y, m, 1 )
      last = first - 1 + DateTime._month_len[ dt.isLeapYear() ][ m ]
      return first.earliestTime(), last.latestTime()

See here for more info:
http://cmf.zope.org/Members/andrew/projects/CMFCalendar/index

Andrew
----- Original Message -----
From: "Marc Fischer" <marcbpc@gmx.de>
To: <zope-cmf@zope.org>
Sent: Thursday, August 23, 2001 4:18 AM
Subject: [Zope-CMF] CMFCalender and monthRange Probs


> Hi I have problems with the monthRange.py from the HowTo:
>
> http://cmf.zope.org/Members/frankmc/UsingCalendarTag
>
> I use CMFCalendar 0.2 and tried nearly all versions of the monthRange.py
:-(
>
> I just followed this hint:
> -------------------------
> Notes
> 1. If you want you can paste the monthRange code into Zope directly but it
> needs modifications. In the Zope management interface, you must add 'dt'
as a
> parameter to the function and paste in the following code :
>
> from DateTime import DateTime
> month_len =((0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
> (0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31))
> """
> Return a pair of DateTime values representing the
> earliest and latest times in the month in which 'dt'
> falls.
> """
> y, m, d = dt.year(), dt.month(), dt.day()
> first = DateTime( y, m, 1 )
> last = first - 1 + month_len[ dt.isLeapYear() ][ m ]
> return first.earliestTime(), last.latestTime()
>
>
> The reason to modify the code is to get around the inability to get to the
> DateTime._month_len attribute because of the Zope engines restrictions.
> -----------------------
>
> but if I try to view the calendar DTML I get the message:
>
> monthRange() takes no arguments (1 given)
>
> ... what to do? Do I have to modify the calendar file, where monthRange is
> calles with an argument???
>
> Thanks for your help ... a frustrated Python Newbie :-)))
>
> --
> GMX - Die Kommunikationsplattform im Internet.
> http://www.gmx.net
>
>
>
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://lists.zope.org/mailman/listinfo/zope-cmf
>
> See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
requests
>