| Store | Cart

html tags and python

From: Patrik Andreasen <p...@botong.org>
Sat, 26 Mar 2005 12:38:27 +0100
Hansan wrote:
> Hi.> > Yeah I also like just to be able to write in numbers.> That is how it works right now.> > But then I will have to make some code, that validates if the day number is > higher than allowed.> Like if it is January, the days arnt allowed to be higher than 31.> > Will one be so kind and explain how I write that code:

Just use the datetime module:

Python 2.4.1a0 (#2, Mar  1 2005, 15:45:39)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> from datetime import date>>> date(2004, 2, 29)
datetime.date(2004, 2, 29)
 >>> date(2005, 2, 29)
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
ValueError: day is out of range for month
 >>>

/patrik

Recent Messages in this Thread
Hansan Mar 25, 2005 10:16 pm
Kane Mar 25, 2005 11:46 pm
Hansan Mar 26, 2005 12:13 am
Swaroop C H Mar 28, 2005 02:27 pm
Dan Bishop Mar 26, 2005 03:46 am
Tim Roberts Mar 26, 2005 09:12 am
Hansan Mar 26, 2005 10:57 am
Patrik Andreasen Mar 26, 2005 11:38 am
gene...@gmail.com Mar 26, 2005 11:49 am
Hansan Mar 26, 2005 03:40 pm
gene...@gmail.com Mar 26, 2005 05:09 pm
EP Mar 27, 2005 02:07 am
Timo Virkkala Mar 30, 2005 05:38 pm
Jeremy Bowers Mar 27, 2005 02:25 am
Hansan Mar 28, 2005 08:12 am
Hansan Mar 28, 2005 04:25 pm
Messages in this thread