How to find out if february has 29 or 28 days ?
John Hunter
jdhunter at ace.bsd.uchicago.edu
Tue Jul 30 11:17:46 EDT 2002
>>>>> "Marcus" == Marcus Vinicius Laranjeira <m.laranjeira at datacraft.com.br> writes:
Marcus> I use the mx.DateTime package, and I need to know if in
Marcus> one particular year has a february with 28 or 29 days ? I
Marcus> don't know how to do that !
Here's one way....
import mx.DateTime
def is_leapyear(year):
try:
d = mx.DateTime.DateTime(year,2,29)
return 1
except mx.DateTime.mxDateTime.RangeError:
return 0
print is_leapyear(2000)
print is_leapyear(2002)
More information about the Python-list
mailing list