Fix sending dates through the protocol

Fixes #253.
This commit is contained in:
Asher
2019-04-04 18:24:21 -05:00
parent 278c59b920
commit e73eb74208
9 changed files with 267 additions and 22 deletions

View File

@@ -65,6 +65,11 @@ export const argumentToProto = (
const arg = new Argument.ProxyValue();
arg.setId(storeProxy(currentValue));
message.setProxy(arg);
} else if (currentValue instanceof Date
|| (currentValue && typeof currentValue.getTime === "function")) {
const arg = new Argument.DateValue();
arg.setDate(currentValue.toString());
message.setDate(arg);
} else if (currentValue !== null && typeof currentValue === "object") {
const arg = new Argument.ObjectValue();
const map = arg.getDataMap();
@@ -136,6 +141,8 @@ export const protoToArgument = (
}
return createProxy(currentMessage.getProxy()!.getId());
case Argument.MsgCase.DATE:
return new Date(currentMessage.getDate()!.getDate());
case Argument.MsgCase.OBJECT:
const obj: { [Key: string]: any } = {};
currentMessage.getObject()!.getDataMap().forEach((argument, key) => {