mod_python, dates, strings and integers

marc.wyburn at googlemail.com marc.wyburn at googlemail.com
Thu Jan 26 18:15:38 CET 2006


when POSTing a date from an mod_python psp page to another the date is
sent as a string. I'm using form.has_key to pull the POST.  I can cut
the string up,turn the strings into integers and then use
datetime.datetime(y,m,d,hr,mn,se) to create a proper datetime.  Is
there a simpler way of doing this.  I ask as I'm working with SQL and
want to keep as much possible in datetime format to avoid confusion/
errors.

snippet

post is; "monday - 01/01/2006"

if form.has_key('day'):
    string_day = form['day']
    textday  = string_day.split("-",1)[0]
    pyday = string_day.split("-",1)[1]
    d,m,y = pyday.split('/',2)
    d = int(d)
    m = int(m)
    y = int(y)
    today = datetime.datetime(y,m,d)



Thanks, Marc.




More information about the Python-list mailing list