time: support float when unpacking time and always set *map
@@ -151,27 +151,29 @@ int flb_time_pop_from_msgpack(struct flb_time *time, msgpack_unpacked *upk,
if(time == NULL || upk == NULL) {
return -1;
}
+
obj = upk->data.via.array.ptr[0];
+ *map = &upk->data.via.array.ptr[1];
switch(obj.type){
case MSGPACK_OBJECT_POSITIVE_INTEGER:
time->tm.tv_sec = obj.via.u64;
time->tm.tv_nsec = 0;
break;
-
+ case MSGPACK_OBJECT_FLOAT:
+ time->tm.tv_sec = obj.via.f64;
+ time->tm.tv_nsec = ((obj.via.f64 - time->tm.tv_sec) * ONESEC_IN_NSEC);
+ break;
case MSGPACK_OBJECT_EXT:
memcpy(&tmp, &obj.via.ext.ptr[0], 4);
time->tm.tv_sec = (uint32_t)ntohl(tmp);
memcpy(&tmp, &obj.via.ext.ptr[4], 4);
time->tm.tv_nsec = (uint32_t)ntohl(tmp);
-
break;
-
default:
flb_warn("unknown time format %x", obj.type);
return -1;
}
- *map = &upk->data.via.array.ptr[1];
return 0;
}
