Created
July 14, 2015 22:28
-
-
Save wtnabe/ab3635663cc85f4f9db3 to your computer and use it in GitHub Desktop.
determin business hour or not with WorkingHours gem
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/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
power_assertと一緒に読み込むと落ちるという致命的な問題発覚…orz