Skip to content

Instantly share code, notes, and snippets.

@wtnabe
Created July 14, 2015 22:28
Show Gist options
  • Save wtnabe/ab3635663cc85f4f9db3 to your computer and use it in GitHub Desktop.
Save wtnabe/ab3635663cc85f4f9db3 to your computer and use it in GitHub Desktop.
determin business hour or not with WorkingHours gem
#! /usr/bin/env ruby
require 'working_hours'
WorkingHours::Config.working_hours = {
mon: {'07:00' => '24:00'},
tue: {'00:00' => '01:00', '07:00' => '24:00'},
wed: {'00:00' => '01:00', '07:00' => '24:00'},
thu: {'00:00' => '01:00', '07:00' => '24:00'},
fri: {'00:00' => '01:00', '07:00' => '24:00'},
sat: {'00:00' => '01:00'}
}
WorkingHours::Config.time_zone = 'Tokyo'
WorkingHours::Config.holidays = Date.new(2015, 8, 8)..Date.new(2015, 8,16)
today = Date.today
t = Time.mktime(today.year, today.mon, today.day, 24, 00, 0)
p t + 10.minutes
p WorkingHours.in_working_hours?(t)
@wtnabe
Copy link
Author

wtnabe commented Jul 15, 2015

power_assertと一緒に読み込むと落ちるという致命的な問題発覚…orz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment