From 95ff60f0c9fabb3a2296dbefb43297cf2029086e Mon Sep 17 00:00:00 2001 From: James Calfee Date: Fri, 17 Feb 2017 09:53:26 -0600 Subject: [PATCH] In serializer time_point_sec, suffix Z (zulu) if a date string is used. close #56 --- src/auth/serializer/src/types.js | 4 ++-- test/all_types.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/auth/serializer/src/types.js b/src/auth/serializer/src/types.js index f76bcea0..81a8ecc9 100644 --- a/src/auth/serializer/src/types.js +++ b/src/auth/serializer/src/types.js @@ -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 ); }, diff --git a/test/all_types.js b/test/all_types.js index 965f6c4e..3a69caea 100644 --- a/test/all_types.js +++ b/test/all_types.js @@ -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. @@ -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", ()=> {