From 9812a7996eb359f0209b99b968d6f4e7c340d3b7 Mon Sep 17 00:00:00 2001 From: Florian Vogt Date: Fri, 25 Feb 2022 08:20:04 +0100 Subject: [PATCH 1/2] [FIX] use UTC date for build timestamp --- lib/tasks/replaceBuildtime.js | 10 +++++----- .../dest/resources/sap/ui/Global-dbg.js | 2 +- .../dest/resources/sap/ui/Global.js | 2 +- test/lib/builder/builder.js | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/tasks/replaceBuildtime.js b/lib/tasks/replaceBuildtime.js index a8e685107..02bfff92b 100644 --- a/lib/tasks/replaceBuildtime.js +++ b/lib/tasks/replaceBuildtime.js @@ -5,11 +5,11 @@ function pad(v) { } function getTimestamp() { const date = new Date(); - const year = date.getFullYear(); - const month = pad(date.getMonth() + 1); - const day = pad(date.getDate()); - const hours = pad(date.getHours()); - const minutes = pad(date.getMinutes()); + const year = date.getUTCFullYear(); + const month = pad(date.getUTCMonth() + 1); + const day = pad(date.getUTCDate()); + const hours = pad(date.getUTCHours()); + const minutes = pad(date.getUTCMinutes()); // yyyyMMdd-HHmm return year + month + day + "-" + hours + minutes; } diff --git a/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global-dbg.js b/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global-dbg.js index 8a2077bdb..e7e8c38ea 100644 --- a/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global-dbg.js +++ b/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global-dbg.js @@ -2,4 +2,4 @@ * Some fancy copyright */ // replacement of $\{buildtime\} is only made in sap/ui/Global.js and Global-dbg.js -console.log('20220620-1630'); +console.log('20220620-1430'); diff --git a/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global.js b/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global.js index b37fec15d..ef4a802c1 100644 --- a/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global.js +++ b/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global.js @@ -1,4 +1,4 @@ /*! * Some fancy copyright */ -console.log("20220620-1630"); \ No newline at end of file +console.log("20220620-1430"); \ No newline at end of file diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index b40fa6d45..d30a3b481 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -863,11 +863,11 @@ test.serial("Build library.coreBuildtime: replaceBuildtime", (t) => { const expectedPath = path.join("test", "expected", "build", "sap.ui.core-buildtime", "dest"); const dateStubs = [ - sinon.stub(Date.prototype, "getFullYear").returns(2022), - sinon.stub(Date.prototype, "getMonth").returns(5), - sinon.stub(Date.prototype, "getDate").returns(20), - sinon.stub(Date.prototype, "getHours").returns(16), - sinon.stub(Date.prototype, "getMinutes").returns(30), + sinon.stub(Date.prototype, "getUTCFullYear").returns(2022), + sinon.stub(Date.prototype, "getUTCMonth").returns(5), + sinon.stub(Date.prototype, "getUTCDate").returns(20), + sinon.stub(Date.prototype, "getUTCHours").returns(14), + sinon.stub(Date.prototype, "getUTCMinutes").returns(30), ]; return builder.build({ From e95132c8af7290e300aa0a29fde7abad4b6e31ab Mon Sep 17 00:00:00 2001 From: Florian Vogt Date: Fri, 25 Feb 2022 11:15:20 +0100 Subject: [PATCH 2/2] [FIX] use ISO 8601 format for build timestamp --- lib/tasks/replaceBuildtime.js | 5 +++-- .../dest/resources/sap/ui/Global-dbg.js | 2 +- .../sap.ui.core-buildtime/dest/resources/sap/ui/Global.js | 2 +- test/lib/builder/builder.js | 1 + test/lib/tasks/replaceBuildtime.js | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/tasks/replaceBuildtime.js b/lib/tasks/replaceBuildtime.js index 02bfff92b..a1732d44f 100644 --- a/lib/tasks/replaceBuildtime.js +++ b/lib/tasks/replaceBuildtime.js @@ -10,8 +10,9 @@ function getTimestamp() { const day = pad(date.getUTCDate()); const hours = pad(date.getUTCHours()); const minutes = pad(date.getUTCMinutes()); - // yyyyMMdd-HHmm - return year + month + day + "-" + hours + minutes; + const seconds = pad(date.getUTCSeconds()); + // yyyy-MM-dd'T'HH:mm:ss'Z' + return year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "Z"; } /** diff --git a/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global-dbg.js b/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global-dbg.js index e7e8c38ea..c1fbbb636 100644 --- a/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global-dbg.js +++ b/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global-dbg.js @@ -2,4 +2,4 @@ * Some fancy copyright */ // replacement of $\{buildtime\} is only made in sap/ui/Global.js and Global-dbg.js -console.log('20220620-1430'); +console.log('2022-06-20T14:30:29Z'); diff --git a/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global.js b/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global.js index ef4a802c1..09d1b19e3 100644 --- a/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global.js +++ b/test/expected/build/sap.ui.core-buildtime/dest/resources/sap/ui/Global.js @@ -1,4 +1,4 @@ /*! * Some fancy copyright */ -console.log("20220620-1430"); \ No newline at end of file +console.log("2022-06-20T14:30:29Z"); \ No newline at end of file diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index d30a3b481..644b14aa1 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -868,6 +868,7 @@ test.serial("Build library.coreBuildtime: replaceBuildtime", (t) => { sinon.stub(Date.prototype, "getUTCDate").returns(20), sinon.stub(Date.prototype, "getUTCHours").returns(14), sinon.stub(Date.prototype, "getUTCMinutes").returns(30), + sinon.stub(Date.prototype, "getUTCSeconds").returns(29) ]; return builder.build({ diff --git a/test/lib/tasks/replaceBuildtime.js b/test/lib/tasks/replaceBuildtime.js index 3344b53b5..03eac21a1 100644 --- a/test/lib/tasks/replaceBuildtime.js +++ b/test/lib/tasks/replaceBuildtime.js @@ -15,7 +15,7 @@ test("integration: replace version", (t) => { const content = "// timestamp: ${buildtime}"; const expectedPrefix = "// timestamp"; - const expectedDatePattern = /^\d{8}-\d{4}$/; + const expectedDatePattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/; const resource = resourceFactory.createResource({ path: "/test.js",