Skip to content

Commit

Permalink
Merge pull request #86 from steemit/56-ff-date-deserialization
Browse files Browse the repository at this point in the history
In serializer time_point_sec, suffix Z (zulu) if a date string is use…
  • Loading branch information
Fabien authored Feb 17, 2017
2 parents 03e0056 + 95ff60f commit a001e55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/auth/serializer/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ Types.time_point_sec = {
if(typeof object !== "string")
throw new Error("Unknown date type: " + object)

// if(typeof object === "string" && !/Z$/.test(object))
// object = object + "Z"
if(typeof object === "string" && !/Z$/.test(object))
object = object + "Z"

return Math.floor( new Date(object).getTime() / 1000 );
},
Expand Down
2 changes: 2 additions & 0 deletions test/all_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ let AllTypes = new Serilizer("all_types", {
time_optional: optional( time_point_sec ),
time_point_sec1: time_point_sec,
time_point_sec2: time_point_sec,
time_point_sec3: time_point_sec,
})

// Must stay in sync with AllTypes above.
Expand All @@ -59,6 +60,7 @@ let allTypes = {
time_optional: undefined,
time_point_sec1: new Date(),
time_point_sec2: Math.floor(Date.now()/1000),
time_point_sec3: '2017-02-16T20:27:12',
}

describe("all types", ()=> {
Expand Down

0 comments on commit a001e55

Please sign in to comment.