Fix offset for SL timestamps
This commit is contained in:
parent
21a2d5f637
commit
985392ec16
16
helpers.js
16
helpers.js
|
@ -1,11 +1,19 @@
|
|||
module.exports = {}
|
||||
const change = 62135659200; // Subtract a year, whoops
|
||||
const change = 62167219200; // Subtract a year, whoops
|
||||
module.exports.convertSLTimestamp = (timestamp) => {
|
||||
//change = 62167219200; // 1 year behind whoops
|
||||
ourTs = Number(BigInt(timestamp) / 10000000n);
|
||||
return new Date((ourTs - change) * 1000)
|
||||
// Convert SCP SL timestamp to seconds since SCP epoch
|
||||
const ourTs = Number(BigInt(timestamp) / 10000000n);
|
||||
|
||||
// Convert to Unix timestamp (seconds since Jan 1, 1970 UTC)
|
||||
const unixTs = ourTs - change;
|
||||
|
||||
// Adjust for local timezone (Mountain Time in this case)
|
||||
const date = new Date(unixTs * 1000); // Convert to milliseconds for JavaScript Date constructor
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
module.exports.toSLTimestamp = (timestamp) => {
|
||||
return String(((Number(timestamp) / 1000) + change) * 10000000)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue