Skip to content

Instantly share code, notes, and snippets.

@d2kagw
Created August 30, 2010 02:33
Show Gist options
  • Save d2kagw/556938 to your computer and use it in GitHub Desktop.
Save d2kagw/556938 to your computer and use it in GitHub Desktop.
class IndexController < ApplicationController
# Monday - Friday
#
# Session 1
# Pacific: 8am-12pm
# GMT: 3pm-7pm
#
# Session 2
# Pacific: 4pm-8pm
# GMT: 11pm-3am
def index
# is it monday - friday?
if DateTime.now.wday > 0 && DateTime.now.wday < 6
# it's monday - friday
# is the time in the two sessions?
if (DateTime.now.hour >= 8 && DateTime.now.hour <= 12) || (DateTime.now.hour >= 16 && DateTime.now.hour <= 20)
@active = "Yes"
else
# it's out of sessions
@active = "No"
end
else
# it's the weekend
@active = "No"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment