Skip to content

Instantly share code, notes, and snippets.

@amsterdamharu
Created August 8, 2023 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amsterdamharu/4399e7582157d21781a4823ab3d4b780 to your computer and use it in GitHub Desktop.
Save amsterdamharu/4399e7582157d21781a4823ab3d4b780 to your computer and use it in GitHub Desktop.
Times when hour and minute hands are 90 degrees
function pad(num: number) {
return `0000${num}`.slice(-2)
}
function time(hour: number) {
return new Date(
`Tue Aug 08 2023 ${pad(hour)}:00:00 GMT+0200 (Central European Summer Time)`
)
}
const times = [
//minute hand has to move 90° back and forward to get 90° angle given hour does not move
[12, -90, 90],
[1, -60, 120],
[2, -30, 150],
[3, 0, 0],
[4, 30, 210],
[5, 60, 240],
[6, -90, 90],
[7, -60, 120],
[8, -30, 150],
[9, 0, 0],
[10, 30, -150],
[11, 60, -120],
].map(([hour, before, after]: number[]) => {
const back = (before / 5.5) * 60000
const forward = (after / 5.5) * 60000
const current = time(hour)
return {
forward: new Date(current.getTime() + forward).toString(),
back: new Date(current.getTime() + back).toString(),
}
})
console.log(times)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment