1

我使用谷歌应用引擎云端点。我有一个类包括由最终用户设置的 DateTimeProperty 属性。

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

我尝试从 javascript 调用端点

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

但无论我尝试什么(例如'12/22/14 19:00',1411130222),服务器总是响应:TypeError:无法反序列化时间戳:09/20/14 11:11am。

有谁知道是否有办法从 javascript 创建 ndb.DateTimeProperty 属性?非常感谢

4

2 回答 2

3

想办法。使用 EndpointsDateTimeProperty 添加解析格式

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

这里有更详细的讨论。 https://github.com/GoogleCloudPlatform/endpoints-proto-datastore/issues/83

于 2014-09-24T12:35:41.063 回答
0

您可能会发现答案很有用。您必须实现一个处理程序,该处理程序将接收一个 JSON 序列化的日期时间对象,将其取消实现为一个日期时间对象并将其存储在数据存储中。

于 2014-09-19T13:07:58.817 回答