Commit a001e55f authored by Fabien's avatar Fabien Committed by GitHub

Merge pull request #86 from steemit/56-ff-date-deserialization

In serializer time_point_sec, suffix Z (zulu) if a date string is use…
parents 03e00568 95ff60f0
...@@ -405,8 +405,8 @@ Types.time_point_sec = { ...@@ -405,8 +405,8 @@ Types.time_point_sec = {
if(typeof object !== "string") if(typeof object !== "string")
throw new Error("Unknown date type: " + object) throw new Error("Unknown date type: " + object)
// if(typeof object === "string" && !/Z$/.test(object)) if(typeof object === "string" && !/Z$/.test(object))
// object = object + "Z" object = object + "Z"
return Math.floor( new Date(object).getTime() / 1000 ); return Math.floor( new Date(object).getTime() / 1000 );
}, },
......
...@@ -34,6 +34,7 @@ let AllTypes = new Serilizer("all_types", { ...@@ -34,6 +34,7 @@ let AllTypes = new Serilizer("all_types", {
time_optional: optional( time_point_sec ), time_optional: optional( time_point_sec ),
time_point_sec1: time_point_sec, time_point_sec1: time_point_sec,
time_point_sec2: time_point_sec, time_point_sec2: time_point_sec,
time_point_sec3: time_point_sec,
}) })
// Must stay in sync with AllTypes above. // Must stay in sync with AllTypes above.
...@@ -59,6 +60,7 @@ let allTypes = { ...@@ -59,6 +60,7 @@ let allTypes = {
time_optional: undefined, time_optional: undefined,
time_point_sec1: new Date(), time_point_sec1: new Date(),
time_point_sec2: Math.floor(Date.now()/1000), time_point_sec2: Math.floor(Date.now()/1000),
time_point_sec3: '2017-02-16T20:27:12',
} }
describe("all types", ()=> { describe("all types", ()=> {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment