Skip to content

Instantly share code, notes, and snippets.

@law
Created August 10, 2015 20:36
Show Gist options
  • Save law/8bef671f156e00962d54 to your computer and use it in GitHub Desktop.
Save law/8bef671f156e00962d54 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'tzinfo'
best_coast = TZInfo::Timezone.get('America/Los_Angeles').strftime('%H') # Returns current hour in LA in 24h format (e.g. '22')
office_hours = (11...18).to_a # local office hours
if office_hours.include?(best_coast)
puts "office in West Coast is open: #{best_coast}"
else
puts "office in West Coast is closed: #{best_coast}"
end
output:
[13:36:17 law@law-mbp:~/sandbox] $ ./businesshours.rb
office in West Coast is closed: 13
[13:36:19 law@law-mbp:~/sandbox] $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment