Skip to content

Instantly share code, notes, and snippets.

@saleehk
Created August 11, 2018 05:37
Show Gist options
  • Save saleehk/bd8330efc0c807ab2c86120c66fba672 to your computer and use it in GitHub Desktop.
Save saleehk/bd8330efc0c807ab2c86120c66fba672 to your computer and use it in GitHub Desktop.
function currentlyOpen () {
var currentDateTime = new Date(); // current time
var hours = currentDateTime.getHours();
var mins = currentDateTime.getMinutes();
var day = currentDateTime.getDay();
return day >= 1 &&
day <= 5 &&
hours >= 9 &&
(hours < 17 || hours === 17 && mins <= 30);
}
function hours (agent) {
if (currentlyOpen()) {
agent.add(`We're open now! We close at 5:30pm today.`);
} else {
agent.add(`We're currently closed, but we open every weekday at 9am!`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment