Re: [Zope] Last day of Month
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Paolo > Quaglia > Sent: Tuesday, December 12, 2000 4:05 AM > To: [EMAIL PROTECTED] > 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. > [EMAIL PROTECTED] > > ___ > Zope maillist - [EMAIL PROTECTED] > 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 ) ___ Zope maillist - [EMAIL PROTECTED] 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 )
RE: [Zope] Last day of Month
On Tue, 12 Dec 2000, 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: > > Hope that helps. See, people used to post helpful little things like this in DTML. What a nightmare. Python Scripts rock! We're gonna be seein' alot more of them fly by on the list once people get over the initial shock that they can do 90% of what they've been doing in Python. -Michel ___ Zope maillist - [EMAIL PROTECTED] 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 )
RE: [Zope] Last day of Month
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Paolo Quaglia Sent: Tuesday, December 12, 2000 4:05 AM To: [EMAIL PROTECTED] 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. [EMAIL PROTECTED] ___ Zope maillist - [EMAIL PROTECTED] 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 )
[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 QuagliaInformation Technology CoordinatorSitek S.p.A.[EMAIL PROTECTED]