Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/tasks/replaceBuildtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ 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());
// yyyyMMdd-HHmm
return year + month + day + "-" + hours + minutes;
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());
const seconds = pad(date.getUTCSeconds());
// yyyy-MM-dd'T'HH:mm:ss'Z'
return year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "Z";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('2022-06-20T14:30:29Z');
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
* Some fancy copyright
*/
console.log("20220620-1630");
console.log("2022-06-20T14:30:29Z");
11 changes: 6 additions & 5 deletions test/lib/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,12 @@ 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),
sinon.stub(Date.prototype, "getUTCSeconds").returns(29)
];

return builder.build({
Expand Down
2 changes: 1 addition & 1 deletion test/lib/tasks/replaceBuildtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down