Business hours processing

  • Thread starter SÅ‚awosz SÅ‚awiÅ„ski
  • Start date
S

Sławosz Sławiński

Hi,
I need to determine how many business hours left to some Time. Do you
know any library with this feature?

SÅ‚awosz
 
A

Ammar Ali

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

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 =3D Time.parse("17:00") - Time.now

If "business hours" means something special, please explain.

Ammar
 
S

Sławosz Sławiński

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
http://github.com/bokmann/business_time 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.
 
J

Josh Cheek

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"))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top