Unverified Commit 1e62a6b4 authored by Sebastian Davids's avatar Sebastian Davids
Browse files

Remove JavaScript example for fixed timezone



Signed-off-by: default avatarSebastian Davids <sdavids@gmx.de>
parent b58115fb
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -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