使用 Scala 创建的 API 的 proto 文件。我的代码是 JS,尝试测试我的代码并收到以下错误:
AssertionError [ERR_ASSERTION]: invalid return value: post[0].lastPublishedDate: Date expected
尝试但未成功的方法:
lastPublishedDate: {seconds: <date>, nano: <date>}
,其中日期是toISOString()中提到的日期,如文档所述(https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto#L115)lastPublishedDate: new Date().toISOString()
- 只需将
2019-02-18T14:18:45.346Z
(这是API调用时返回的内容)作为日期。
我在网上找到的唯一其他相关信息是https://github.com/dcodeIO/protobuf.js/issues/437,看起来也没有解决。
有人能够在JS中使用google.protobuf.Timestamp吗?
setSeconds
和setNanos
由于某些原因对我无效,但是fromDate
有效。谢谢! - Neurotransmitter