Last active
March 25, 2022 23:13
-
-
Save mezerotm/da8e9a561bfb834667894839a3b19146 to your computer and use it in GitHub Desktop.
Some common operations I perform with Unix time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SECONDS_IN_A_DAY = 86400 | |
let sts = 1629072000 | |
let ets = 0 | |
const unixMidnight = time => { | |
return time - (time % SECONDS_IN_A_DAY) | |
} | |
const addDay = time => { | |
return time + SECONDS_IN_A_DAY | |
} | |
const getNextDays = (time, nextDays) => { | |
const days = [] | |
for (let i = 0; i < nextDays; i++) { | |
days.push(time) | |
time = addDay(time) | |
} | |
return days | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment