Skip to content

Instantly share code, notes, and snippets.

@ricardobrg
Last active December 2, 2019 19:12
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 ricardobrg/6486b542f810904f254658799c48d310 to your computer and use it in GitHub Desktop.
Save ricardobrg/6486b542f810904f254658799c48d310 to your computer and use it in GitHub Desktop.
function is_happening_now(talk) {
// take talk.datetime in ms from epoch
let talkTime = new Date(talk.datetime).getTime();
// calculate talkend in ms from epoch
let talkEnd = talkTime + (talk.duration * 60000);
// take current epoch time in browser`s timezone
let now = new Date().getTime();
// Return boolean true if talk is happening now or false.
return now > talkTime && now < talkEnd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment