Maurits van Rees wrote:
Eric, on 2007-08-26:
To work around this, I've modified the addition so that instead of adding 1 day, it adds 1.5 days. This extra half a day is removed by the theDateTime.earliestTime() call but is enough to overcome the DST addition problem. Ugly hack.


I had the same problem once in the eXtremeManagement Plone product.
For a monthly overview I needed to do something for every day of the
month.  I worked around it with the code below.

    day = 1
    date = DateTime(2007, 10, 1) # 1 October 2007
    while True:
        # skipped some lines irrelevant to the DateTime problem
        day += 1
        try:
            date = DateTime(self.year, self.month, day)
        except:
            break

Hm, that should probably be "except DateTime.DateTime.DateError" but
there is not really anything else that can go wrong here.

A ConflictError can go wrong here, which is an additional and important reason not to have a bare except. There are good reasons without that, as well.

        --jcc


--
Connexions
http://cnx.org

"Building Websites with Plone"
http://plonebook.packtpub.com

_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to