1

I use Google app engine cloud endpoint. One class I have including a DateTimeProperty property to be set by end user.

class Schedule(EndpointsModel):
  id = ndb.StringProperty()
  scheduleTime = ndb.DateTimeProperty()
  created = ndb.DateTimeProperty(auto_now=True)

and I try to call the endpoint from the javascript

gapi.client.myendpoints.schedules.insert({
    'id': 11121,
    'scheduleTime ': '12/22/14 19:00'
    }).execute()

But no matter what I tried (such as '12/22/14 19:00',1411130222) the server always responses: TypeError: Could not deserialize timestamp: 09/20/14 11:11am.

Does anyone know if there is a way to create a ndb.DateTimeProperty property from javascript? Thanks a lot

Vincent Zhou
  • 503
  • 1
  • 6
  • 17

2 Answers2

3

Figure it out. use the EndpointsDateTimeProperty to add the parse format

myDate= EndpointsDateTimeProperty(string_format='%m/%d/%y %H:%M')

Here is more detailed discussion. https://github.com/GoogleCloudPlatform/endpoints-proto-datastore/issues/83

Vincent Zhou
  • 503
  • 1
  • 6
  • 17
0

You may find this answer useful. You'll have to implement a handler that will receive a JSON serialized datetime object, deserealize it to a datetime object and store it in the datastore.

Community
  • 1
  • 1
Nikita Uchaev
  • 1,164
  • 5
  • 16