Loading _docs/source-date-epoch.md +1 −9 Original line number Diff line number Diff line Loading @@ -374,19 +374,11 @@ def buildDate = System.getenv("SOURCE_DATE_EPOCH") == null ? new java.util.Date(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH"))) ``` ### Javascript / Node.js ### JavaScript / Node.js ```javascript const epoch = Number(process.env["SOURCE_DATE_EPOCH"]); const timestamp = Number.isInteger(epoch) ? new Date(epoch * 1000) : new Date(); // Alternatively, to ensure a fixed timezone: const epoch = Number(process.env["SOURCE_DATE_EPOCH"]); var timestamp = new Date(); if (Number.isInteger(epoch)) { timestamp = new Date((epoch * 1000) + (timestamp.getTimezoneOffset() * 60000)); } ``` ### Coffeescript Loading Loading
_docs/source-date-epoch.md +1 −9 Original line number Diff line number Diff line Loading @@ -374,19 +374,11 @@ def buildDate = System.getenv("SOURCE_DATE_EPOCH") == null ? new java.util.Date(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH"))) ``` ### Javascript / Node.js ### JavaScript / Node.js ```javascript const epoch = Number(process.env["SOURCE_DATE_EPOCH"]); const timestamp = Number.isInteger(epoch) ? new Date(epoch * 1000) : new Date(); // Alternatively, to ensure a fixed timezone: const epoch = Number(process.env["SOURCE_DATE_EPOCH"]); var timestamp = new Date(); if (Number.isInteger(epoch)) { timestamp = new Date((epoch * 1000) + (timestamp.getTimezoneOffset() * 60000)); } ``` ### Coffeescript Loading