我想知道为什么某些字段之间的日期格式不同。我的规则是这样声明的:
@Name("measurement_occupation")
context ParkingSpotOccupation
insert into CreateMeasurement
select
e.source as source,
"ParkingSpotOccupation" as type,
min(e.time) as time,
{
"startDate", min(e.time),
"endDate", max(e.time),
"duration", dateDifferenceInSec(max(e.time), min(e.time))
} as fragments
from
SmartParkingEvent e
output
last when terminated;
使用 API 测量结果如下:
{
"time": "2016-05-30T06:00:00.000+02:00",
"id": "33200",
"self": "https://management.post-iot.lu/measurement/measurements/33200",
"source": {
"id": "26932",
"self": "https://management.post-iot.lu/inventory/managedObjects/26932"
},
"type": "ParkingSpotOccupation",
"startDate": {
"time": 1464580800000,
"minutes": 0,
"seconds": 0,
"hours": 6,
"month": 4,
"timezoneOffset": -120,
"year": 116,
"day": 1,
"date": 30
},
"duration": 600,
"endDate": {
"time": 1464581400000,
"minutes": 10,
"seconds": 0,
"hours": 6,
"month": 4,
"timezoneOffset": -120,
"year": 116,
"day": 1,
"date": 30
}
}
为什么吃时间和 startDate/endDate 呈现不同?更奇怪的是,当显示我的事件处理规则的输出时,它的格式如下:
{ "time": { "date": 30, "day": 1, "hours": 6, "minutes": 0, "month": 4, "seconds": 0, "time": 1464580800000, "timezoneOffset": -120, "year": 116 }, "source": "26932", "fragments": [ "startDate", { "date": 30, "day": 1, "hours": 6, "minutes": 0, "month": 4, "seconds": 0, "time": 1464580800000, "timezoneOffset": -120, "year": 116 }, "endDate", { "date": 30, "day": 1, "hours": 6, "minutes": 10, "month": 4, "seconds": 0, "time": 1464581400000, "timezoneOffset": -120, "year": 116 }, "duration", 600 ], "type": "ParkingSpotOccupation" }
所以每个日期看起来都一样,但当我使用 API 访问测量值时却不同。我希望所有日期都以这种格式存储:“2016-05-30T06:00:00.000+02:00”。我也尝试使用 cast(min(e.time), Date) 但出现错误(无法加载名称为“日期”的 cast 函数中列出的类)。我尝试了 toDate() 函数,但它没有改变任何东西。