How can I "stuff" or convert a time.struct_time into a
db.DateTimeProperty field?
I'm converting an XML date/time in this format: "2009-05-20
04:24:11.715000", and I can parse into a time.struct_time (see code
below), but then cannot set the db field from teh struct_time.

Thanks,
Neal Walters

CODE:

import datetime
import time
import sys
import os
from google.appengine.ext import db

class MyTable(db.Model):
  eventStartedDateTime   = db.DateTimeProperty(auto_now=False)

def fixdate(datein):
        position = datein.find(".")
        print "position=" + str(position)
        date2=datein
        if position > 1:
           date2 = datein[0:position]
        print "date2=" + date2
        newdate = time.strptime(date2, "%Y-%m-%d %H:%M:%S")
        print "newdate= " + str(newdate)
        print newdate
        return newdate

xmlDate = "2009-05-20 04:24:11.715000"
print "original date = " + xmlDate
print "fixdate(xmlDate)=" + str(fixdate(xmlDate))
mytable1 = MyTable()
mytable1.eventStartedDateTime = fixdate(xmlDate)

OUTPUT:
date2=2009-05-20 04:24:11
newdate= time.struct_time(tm_year=2009, tm_mon=5, tm_mday=20,
tm_hour=4, tm_min=24, tm_sec=11, tm_wday=2, tm_yday=140, tm_isdst=-1)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to