2010/6/11 S=C5=82awosz S=C5=82awi=C5=84ski said:
Hi,
I need to determine how many business hours left to some Time. Do you
know any library with this feature?
S=C5=82awosz
From
http://www.rubyinside.com/3-new-date-and-time-libraries-for-rubyists-3238.h=
tml
business_time - Time and date offsets based on "business time/hours"
business_time is a new library that works with the concept of "business
time" or "business hours." Rather than just letting you perform operations
on dates by absolute numbers of days or hours, you can now work with
business days and hours of your own definition. business_time depends
heavily on Active Support.
To install:
gem install business_time
Note: business_time depends on Active Support (gem: activesupport)
To use:
require 'active_support'
require 'business_time'
# Examples "from now"
4.business_hours.from_now
5.business_days.from_now
# Using user supplied dates
my_birthday =3D Date.parse("August 4th, 2010")
10.business_days.before(my_birthday)
# Add a day to not count as a business day
BusinessTime::Config.holidays << my_birthday
# Overlapping days are OK
6.business_hours.after(Time.parse("August 3rd, 3:00pm"))