Hi,
I need to determine how many business hours left to some Time. Do you
know any library with this feature?
SÅ‚awosz
Hi,
I need to determine how many business hours left to some Time. Do you
know any library with this feature?
SÅ‚awosz
2010/6/11 Sławosz Sławiński [email protected]:
Hi,
I need to determine how many business hours left to some Time. Do you
know any library with this feature?SÅ‚awosz
Posted via http://www.ruby-forum.com/.
Not sure what you mean by “business hours”, but if it is the same a
regular hour, and you have an end time (5 PM, for example) you can
simply subtract the two time objects. For example:
time_left = Time.parse(“17:00”) - Time.now
If “business hours” means something special, please explain.
Ammar
Not sure what you mean by “business hours”, but if it is the same a
regular hour, and you have an end time (5 PM, for example) you can
simply subtract the two time objects. For example:time_left = Time.parse(“17:00”) - Time.now
If “business hours” means something special, please explain.
It means this. For example, there is
GitHub - bokmann/business_time: Support for doing time math in business hours and days but I need somethink like
Time.now.business_time_left_to(Time.parse(“Aug 5 2010, 9:35 am”))
and it should returns how many business hours and minutes left.
Or I will fork business_time gem.
Thanks,
as solution, I wrote very simple extension to business_time:
I wish it would help someone
SÅ‚awosz
2010/6/11 Sławosz Sławiński [email protected]
Hi,
I need to determine how many business hours left to some Time. Do you
know any library with this feature?SÅ‚awosz
Posted via http://www.ruby-forum.com/.
From
http://www.rubyinside.com/3-new-date-and-time-libraries-for-rubyists-3238.html
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’
4.business_hours.from_now
5.business_days.from_now
my_birthday = Date.parse(“August 4th, 2010”)
10.business_days.before(my_birthday)
BusinessTime::Config.holidays << my_birthday
6.business_hours.after(Time.parse(“August 3rd, 3:00pm”))
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs