Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
added offset (hope) (#7)
Browse files Browse the repository at this point in the history
* let count sols :)

* :)

* Added percentage

* Made 24 hours discord timer to calculate the offset and fix the time

* Made 24 hours discord timer to calculate the offset and fix the time
  • Loading branch information
SushiBtw authored Feb 19, 2021
1 parent 88db0e4 commit 8cb0786
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.vs/
21 changes: 14 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ const day = 24 * 60 * 60;
const landingTimestamp = 1613681692;

function getMSD(earthTimestamp) {
return (julian(earthTimestamp) - 2405522.0028779) / 1.0274912517;
return (julian(earthTimestamp) - 2405522.0028779) / 1.0274912517;
}
function getMission() {
const date = Date.now();
return {
sol: Math.floor(getMSD(date) - getMSD(new Date(landingTimestamp * 1000).getTime())),
percentage: ((getMSD(date) - getMSD(new Date(landingTimestamp * 1000).getTime()))*100).toFixed(2)
}
const date = Date.now();
let sol = Math.floor(getMSD(date) - getMSD(new Date(landingTimestamp * 1000).getTime()));
let percentage = ((getMSD(date) - getMSD(new Date(landingTimestamp * 1000).getTime())) * 100).toFixed(2);
let _day = new Date(landingTimestamp * 1000);
_day.setDate(_day.getDate() + sol);
_day = new Date(_day.getTime() + new Date(day * percentage).getTime());

return {
sol,
percentage,
offset: _day.getTime()
}
}

const rpcClient = new Client({ transport: 'ipc' });
Expand Down Expand Up @@ -48,7 +55,7 @@ function update() {
rpcClient.setActivity({
state,
details,
startTimestamp: landingTimestamp,
startTimestamp: missionInfo.offset,
largeImageKey: 'ps',
largeImageText: 'Nasa is running this mission!',
buttons,
Expand Down

0 comments on commit 8cb0786

Please sign in to comment.