-
-
Save law/8bef671f156e00962d54 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
#!/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