Created
July 27, 2015 22:45
-
-
Save JoniWeiss/0f95b79f46557cca0328 to your computer and use it in GitHub Desktop.
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
var areWeOpen = function() { | |
var bizHours = [ | |
["0900", "1800"], | |
["0630", "2000"], | |
["0630", "2000"], | |
["0630", "2000"], | |
["0630", "2000"], | |
["0630", "2000"], | |
["0800", "2000"] | |
]; | |
var today = moment().format("e"); | |
var tomorrow = moment().add(1, 'days').format("e"); | |
var open = moment(bizHours[today][0], "HHmm").format("HHmm"); | |
var close = moment(bizHours[today][1], "HHmm").format("HHmm"); | |
var now = moment(now).format("HHmm"); | |
var openStatus = function () { | |
var status = "Closed"; | |
if (open <= now && now < close) { | |
status = "We are Open now... Why aren't you here?"; | |
} else { | |
status = "We are closed and will re-open tomorrow morning at " + | |
moment(bizHours[tomorrow][0], "HHmm").format("HH[:]mm a"); | |
} | |
return status; | |
}; | |
return openStatus(); | |
} | |
alert(areWeOpen()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires the moment.js plugin. Use as you see fit.
Please let me know what changes you might make or suggest :)
I created this to be able to display the status of the business for the day on their website.