Fix offset for SL timestamps

This commit is contained in:
Christopher Cookman 2024-07-22 16:11:31 -06:00
parent 21a2d5f637
commit 985392ec16
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -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)
}