Skip to content

Instantly share code, notes, and snippets.

@nhocki
Created October 10, 2014 19:53
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 nhocki/e865baa10a6d98cf3726 to your computer and use it in GitHub Desktop.
Save nhocki/e865baa10a6d98cf3726 to your computer and use it in GitHub Desktop.
Disable something if not on a specific time-frame // day
def office_hours?
Time.use_zone('Pacific Time (US & Canada)') do
# window = Time.zone.parse("2014-04-30")
now = Time.zone.now
start, finish = Time.zone.parse('9:30'), Time.zone.parse('16:30')
now.between?(start, finish) # && now.yday == window.yday
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment