[Zope] Last day of Month
Jose Soares
jose@sferacarta.com
Wed, 13 Dec 2000 17:11:42 +0100
Use an External Method like this one.
# Perché non usare un metodo esterno?
from DateTime import Date
def lastDay(year,month):
try:
last = Date(year,month+1,1)-1
return last.day
except:
return 31
José
Eric Walstad wrote:
> Hi Paolo,
> I have a Python Metho... er Python Script that I use that tells me the days
> in each month. You pass in a Zope DateTime object as a parameter and it
> returns the days in that month:
>
> Parameters: ZopeDateTime
> Code:
> -----8<-- Start Snip --8<-----
> if ZopeDateTime.isLeapYear():
> intDaysInFebruary = 29
> else:
> intDaysInFebruary = 28
>
> strMonthName=ZopeDateTime.Month()
>
> dicDaysPerMonth =
> {'January':31,'February':intDaysInFebruary,'March':31,'April':30,'May':31,'J
> une':30,'July':31,'August':31,'September':30,'October':31,'November':30,'Dec
> ember':31}
>
> return dicDaysPerMonth.get(strMonthName, 0)
> -----8<-- End Snip --8<-----
>
> Hope that helps.
>
> Eric.
>
> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Paolo
> Quaglia
> Sent: Tuesday, December 12, 2000 4:05 AM
> To: zope@zope.org
> Subject: [Zope] Last day of Month
>
> Hi everibody
> Is there some tricky way to know the last day of the month of a DateTime
> object?
> for ex: if my DateTime object is 12/12/2000 .... is there a method or a
> function that return the last day of the month? (in this example 31)
>
> Thanks a lot
> Paolo Quaglia
> Information Technology Coordinator
> Sitek S.p.A.
> paolo@sitek.it
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )