bokmann / business_time Goto Github PK
View Code? Open in Web Editor NEWSupport for doing time math in business hours and days
License: MIT License
Support for doing time math in business hours and days
License: MIT License
I noticed that we are missing January 30 and Feburary 27 as business days in 2015. Is there a reason for this?
2.1.4 :006 > date = "2015-03-01".to_date
=> Sun, 01 Mar 2015
2.1.4 :007 > 1.business_day.before(date)
=> Thu, 26 Feb 2015 00:00:00 UTC +00:00
I loved shoulda, but its best days are behind it. I wish I liked rspec, but I don't. Minitest and minitest-should feel pretty nice to me.
Time.first_business_day(time_off_request.date_requested)
undefined method `first_business_day' for Time:Class (Also did not work for date class).
time_off_request.num_days.business_days.after(time_off_request.date_requested) does work so library is generally working
Even example on readme page not working
= Time.first_business_day(Time.parse("Sat Aug 9, 18:00:00, 2014"))
Method still available?
Ruby 2.2.1 Rails 4.2
I ran into a very similar issue as #36, but different enough that I think it deserves a new ticket. I had a script using Business Time that was working just fine for a long time. As soon as I tried to integrate it into my Rails environment, my times started getting butchered. Here is the logic that seemed to be causing my issues:
https://github.com/bokmann/business_time/blob/develop/lib/business_time/time_extensions.rb#L107
Before I integrated Rails, Time.zone was nil. After adding Rails, Time.zone was always set to UTC. My timezone that I was trying to use (passed in the "time" variable) was in UTC-400.
For now I've solved this by setting my Rails timezone to the same timezone that I'm passing into my Business Time functions and that seems to have solved it, however as Business Time is supposed to be timezone agnostic, it would be nice to see this fixed and be able to go back to UTC in my rails app.
Edit: removed note about the new release that was mentioned in #36 after I noticed that the discussion was over a year old.
I am trying to test a service which provides calculated deadlines for records. My test goes something like this:
require 'rails_helper'
RSpec.describe CalculateDeadline, type: :model do
describe 'for priority certificates' do
let(:certificate) { create :certificate, service_level: 'priority' }
it 'returns 3 business days' do
expect(CalculateDeadline.call certificate).to eq 3.business_days
end
end
end
Of course, this fails miserably since there are no comparison methods provided and the two times are separate instances of BusinessTime::BusinessDays
and as such not identical.
Can we add an equality evaluation method. If not, please explain how else I should test my code without either creating two Time
instances to compare, or poking about in the instance with something like 3.business_days.instance_variable_get('@days')
.
Loading dates from the yml file results in the holiday array containing a bunch of TimeZone objects... The weird thing is that the dates are parsed correctly. Tracing what is read and what is stored gives me this:
data["business_time"]["holidays"].each do |holiday|
STDERR.puts "Got holiday #{holiday}; parsing to #{Time.zone.parse( holiday ).class}"
self.holidays <<
Time.zone ? Time.zone.parse(holiday) : Time.parse(holiday)
STDERR.puts "Stored: #{self.holidays.last.class}"
end
Got holiday 2010-12-24; parsing to ActiveSupport::TimeWithZone
Stored: ActiveSupport::TimeZone
Adding directly to the array in the initializer seems to work. Maybe some magic is going on in the Rails background that not everything regarding Times and Zones are loaded at the time the initializer is run.
The code for business_days_until is as follows:
def business_days_until(to_date)
(self...to_date).select{ |day| day.workday? }.size
end
According to the Range on ruby the way is being done, it is excluding the last day. On my understanding the until you have to include the day you are passing as to_date.
Hence the function should look like:
def business_days_until(to_date)
(self..to_date).select{ |day| day.workday? }.size
end
This way it includes the to_date inside the range and it takes it into account.
I am using the business time gem and it seems that holidays are not being accounted for. Here's an example of what my config looks like and some console outputs.
/config/business_time.yml:
business_time:
beginning_of_workday: 8:00 am
end_of_workday: 1:00 pm
holidays:
- Feb 18th, 2013
- May 27th, 2013
- July 4th, 2013
- Sep 2nd, 2013
- Nov 28th, 2013
- Nov 29th, 2013
- Dec 25th, 2013
- Dec 31st, 2013
- Jan 1st, 2014
work_week:
- mon
- tue
- wed
- thu
- fri
in Rails console:
1.9.3p327 :024 > BusinessTime::Config.holidays
=> [Mon, 18 Feb 2013 00:00:00 PST -08:00, Mon, 27 May 2013 00:00:00 PDT -07:00, Thu, 04 Jul 2013 00:00:00 PDT -07:00, Mon, 02 Sep 2013 00:00:00 PDT -07:00, Thu, 28 Nov 2013 00:00:00 PST -08:00, Fri, 29 Nov 2013 00:00:00 PST -08:00, Wed, 25 Dec 2013 00:00:00 PST -08:00, Tue, 31 Dec 2013 00:00:00 PST -08:00, Wed, 01 Jan 2014 00:00:00 PST -08:00]
1.9.3p327 :025 > Time.now
=> 2013-05-21 14:57:18 -0700
1.9.3p327 :026 > 4.business_days.from_now
=> Mon, 27 May 2013 14:57:42 PDT -07:00
it clearly shows may 27th as a holiday, yet it chooses may 27th as a viable business day. Same with July 4th.
I don't think its a timezone issue because july 3rd and july 5th don't trigger as a holiday either.
1.9.3p327 :021 > 31.business_days.from_now
=> Wed, 03 Jul 2013 14:56:21 PDT -07:00
1.9.3p327 :022 > 32.business_days.from_now
=> Thu, 04 Jul 2013 14:56:24 PDT -07:00
1.9.3p327 :023 > 33.business_days.from_now
=> Fri, 05 Jul 2013 14:56:28 PDT -07:00
My project gem specs:
ruby 1.9.3p327
rails 3.2.11
business_time 0.6.1
EDIT:
it seems that updating the config.time_zone in application.rb is causing the issue. FOr instance, if i set:
config.time_zone = 'Pacific Time (US & Canada)'
then business_time holidays fail.
It would be great to have a method to get the number of business days between 2 dates.
activesupport
has a dependency on tzinfo ~> 0.3.37
please consider following code:
require 'json'
require 'date'
require 'business_time'
mydate = Date.parse("April 23, 2014")
printf "10 days after %d-%d-%d\n ", mydate.year, mydate.month, mydate.day
printf "using 10.business_days.after(<date>)\n"
print 10.business_days.after(mydate)
print "\n\n"
mydate = Date.parse("April 21, 2014")
printf "10 days after %d-%d-%d\n ", mydate.year, mydate.month, mydate.day
printf "using 10.business_days.after(<date>)\n"
print 10.business_days.after(mydate)
print "\n"
result:
10 days after 2014-4-23
using 10.business_days.after(<date>)
2014-05-06 17:00:00 -0700
10 days after 2014-4-21
using 10.business_days.after(<date>)
2014-05-05 17:00:00 -0700
expected the computed days to be 2 days apart.
Default configs. Saturday says 1 business day after is Monday. Friday says one business day after is Friday (itself). Thursday says 1 business day after is Thursday (itself). Sunday says 1 business day after is Tuesday. Would expect it to be Monday; same answer for Saturday since weekend is non-business day.
2.1.2 :014 > d = Date.parse("2015-03-28")
=> Sat, 28 Mar 2015
2.1.2 :015 > 1.business_days.after(d)
=> Mon, 30 Mar 2015 20:00:00 EDT -04:00
2.1.2 :016 > d = Date.parse("2015-03-29")
=> Sun, 29 Mar 2015
2.1.2 :017 > 1.business_days.after(d)
=> Tue, 31 Mar 2015 20:00:00 EDT -04:00
2.1.2 :018 > d = Date.parse("2015-03-27")
=> Fri, 27 Mar 2015
2.1.2 :019 > 1.business_days.after(d)
=> Fri, 27 Mar 2015 20:00:00 EDT -04:00
2.1.2 :020 > d = Date.parse("2015-03-26")
=> Thu, 26 Mar 2015
2.1.2 :021 > 1.business_days.after(d)
=> Thu, 26 Mar 2015 20:00:00 EDT -04:00
2.1.2 :022 >
Your gem is excelent but there is little feature that I need and I would like to know if it could be added to the gem.
I need to define working hours for a given week day without the lunch time. For instance, work hours would be from 9:00 to 12:00 and from 13:00 to 18:00. Basically I would like to configure work hours with something like this:
BusinessTime::Config.work_hours = {
:mon=>["9:00","12:00","13:00","18:00"],
:tue=>["9:00","12:00","13:00","18:00"],
:wed=>["9:00","12:00","13:00","18:00"],
:thu=>["9:00","12:00","13:00","18:00"],
:fri=>["9:00","12:00","13:00","18:00"],
:sat=>["10:00","15:00"]
}
Dependency to tzinfo in Rails 3.2.16 is:
rails (= 3.2.16) ruby depends on
tzinfo (~> 0.3.29) ruby
This incompatibility should be mentioned: the version 0.6.2 is the latest compatible with Rails 3.2.x
gem 'business_time', '~> 0.6.2'
There's a set of enclosing parentheses missing in file lib/business_time/config.rb, line 50. As is, I get TimeZone objects:
prompt$ script/runner 'puts BusinessTime::Config.holidays.collect(&:to_s)'
(GMT-05:00) Eastern Time (US & Canada)
(GMT-05:00) Eastern Time (US & Canada)
...
Changing the line to "(Time.zone ? Time.zone.parse(holiday) : Time.parse(holiday))", it works fine:
prompt$ script/runner 'puts BusinessTime::Config.holidays.collect(&:to_s)'
2010-01-01 00:00:00 -0500
2010-01-18 00:00:00 -0500
...
The gem's version number suddenly bump from 0.4.0 to 0.6.1, and drop support for rails 2.
So, some features, such as Time.business_time_until
doesn't exist on v0.4.0, that means I cannot use this on a rails 2 app.
And I've saw a 0.5.0.pre
commit message in git logs. but it seems that this version had never been released?
And also the README never mention will drop support for rails 2.
I've noticed an inconsistency between business_days_until
and business_days.after
.
>> sat = Date.parse("2006-01-07")
>> mon = Date.parse("2006-01-09")
>> tue = Date.parse("2006-01-10")
>> 1.business_days.after(sat).to_date
=> Mon, 09 Jan 2006
>> sat.business_days_until(mon)
=> 0
>> sat.business_days_until(tue)
=> 1
As you can see, one business day after saturday is monday, but there is 0 business days until monday and 1 business days untils tuesday. For me, adding days to weekend day should look like:
>> 1.business_day.after(sat).to_date
=> Tue, 10 Jan 2006
Let's say that I claim on my website that I will respond to emails within 1 business day. If someone send me an email on saturday, for me it's the same as they would send it on monday. I will read it on monday, so I would like to be able to respond on tuesday, not on monday. business_days_until
seems to work with that in mind, but business_days.after
acts differently.
Would you agree to change the implementation to match the above example?
Idea of this gem is awesome and it almost did what I need. But it seems working time configuration made almost impossible to work with several business time schedules in the same application. For example, I need to deal bank business time and call center business time. Bank usually set it's own business time, but call center has extended availability and almost no holidays ...
Is there a way to solve this issue without hard fixing the core of business_time
gem?
added gem 'business_time' to my rails 3.2.13 with ruby 1.9.3 project.
I'm getting the following error:
1.9.3p448 :015 > Time.now.during_business_hours?
NoMethodError: undefined method `during_business_hours?' for DateTime:Class
Any ideas?
Please consider the following:
date = '12-Jan-2015'.to_date
=> Mon, 12 Jan 2015
1.business_day.before(date)
=> Fri, 09 Jan 2015 00:00:00 UTC +00:00date = '11-Jan-2015'.to_date
=> Sun, 11 Jan 2015
1.business_day.before(date)
=> Thu, 08 Jan 2015 00:00:00 UTC +00:00
Same result if I set:
BusinessTime::Config.work_week = %w[mon tue wed thu fri]
It looks like a bug or am I missing any relevant setting?
Thanks.
business_time is great gem but I wanted to know can I use it for multiple business hours for multiple records for example I have multiple records of restaurants which have different business timings like this
[
Mon: {
morning: {
from: 9:00 am, to: 12:00 pm
},
noon:{
from: 2:00 am, to: 5:00 pm
},
night{
from: 7:00pm to: 11:pm
}
},
Tue: {
morning: {
from: 10:00 am, to: 12:00 pm
},
noon:{
from: 1:00 am, to: 5:00 pm
},
night: {
from: 7:00pm to: 11:pm
}
},
Wed: {
morning: {
from: 9:30 am, to: 12:00 pm
},
noon:{
from: 1:30 am, to: 5:00 pm
},
night:{
from: 7:00pm to: 11:pm
}
},
Thu:{
morning: {
from: 9:00 am, to: 01:00 pm
},
noon:{
from: 1:00 am, to: 5:00 pm
},
night:
{
from: 7:00pm to: 11:pm
}
},
Fri:{
morning: {
from: 9:00 am, to: 01:00 pm
},
noon:{
from: 1:00 am, to: 5:00 pm
},
night:{
from: 7:00pm to: 11:pm
}
}
Sat: off
Sun: off
]
Can I use this gem for to implement this? if yes then How?
Thanks for such great work.
Is it possible to supply multiple sets of configurations using ActiveRecord? It is possible to have different working days and holiday days for a multi-location based company.
Thanks a lot
I'm getting this with ruby 2.1.1
business_time-0.7.2/lib/business_time/config.rb:76: warning: method redefined; discarding old end_of_workday
business_time-0.7.2/lib/business_time/config.rb:31: warning: previous definition of end_of_workday was here
business_time-0.7.2/lib/business_time/config.rb:85: warning: method redefined; discarding old beginning_of_workday
business_time-0.7.2/lib/business_time/config.rb:31: warning: previous definition of beginning_of_workday was here
business_time-0.7.2/lib/business_time/config.rb:94: warning: method redefined; discarding old work_week=
business_time-0.7.2/lib/business_time/config.rb:34: warning: previous definition of work_week= was here
I am having some issues with these two functions. They are not giving me consistent results. For instance:
the following example works. start date is feb 11th, delivery date is feb 13th. 2.business_days_after returns the 13th, which is expected. .business_days_until returns 2 business days which is expected.
start_date => Wed, 11 Feb 2015 12:00:00 -0800
delivery_date = 2.business_days.after(start_date) => Fri, 13 Feb 2015 12:00:00 PST -08:00
start_date.business_days_until(delivery_date) => 2
However, lets add a weekend and a holiday (feb 16th is a holiday in config) into the mix
start_date => Wed, 11 Feb 2015 12:00:00 -0800
delivery_date = 3.business_days.after(start_date) => Tue, 17 Feb 2015 12:00:00 PST -08:00
start_date.business_days_until(delivery_date) => 4
.business_days_until is returning 4 business days instead of the expected 3.
Just curious on the timetable for getting this to work with Ruby 1.9.3-rc1, as this doesn't appear to work properly:
ruby-1.9.3-rc1 :031 > my_birthday = Date.strptime("04-08-2012", "%d-%m-%Y")
=> Sat, 04 Aug 2012
ruby-1.9.3-rc1 :032 > 10.business_days.before(my_birthday)
=> Mon, 26 Mar 2012 00:00:00 CDT -05:00
Thanks.
I see some nice activity on master branch. 0.6.1 seems to be 1-9-3-support branch.
Is there a release date of the master branch?
Many of our holidays are repeated year to year. These generally falling to an easy pattern. First Monday in September or December 25th.
I've looked but can't find if patterns are currently acceptable in business_time.yml file. If not, do you think it would be a worthwhile change? If so, I can work on and submit a pull request.
deadline = Time.parse("Mon, 29 Sep 2014, 09:00 am")
30.business_minutes.before(deadline)
The latest version of business_time does not seem to handle calculating business_days.after() based on a date/time that starts outside business hours.
An example:
irb(main):001:0> d=Time.parse("Saturday, August 17, 12:54am")
=> Sat Aug 17 00:54:00 -0700 2013
irb(main):002:0> 1.business_day.after(d)
=> Tue, 20 Aug 2013 00:54:00 PDT -07:00
It seems that business_days.after is completely ignoring the time, which seems to be wrong. It also seems to have the day off by one as 1 business day after should be the EOBD on Monday.
I think c332491 warrants putting out a bug fix release.
Hello,
Assuming
current issue is :
5.hours.ago.business_time_until 1.hours.ago
# => 7200.00005698204 // 2 hours
5.hours.ago.to_time.business_time_until 1.hours.ago.to_time
# => 14400.000063 // 4 hours
So 5 hours - 1 hours = 4 hours, the correct result is :
5.hours.ago.to_time.business_time_until 1.hours.ago.to_time
So why these 2 results are different ?
5.hours.ago.class
# => ActiveSupport::TimeWithZone
5.hours.ago.to_time
# => Time
Basically the main difference is the class used when dealing with business_time_until Time vs ActiveSupport::TimeWithZone
https://github.com/bokmann/business_time/blob/master/lib/business_time/core_ext/time.rb#L100 when using an ActiveSupport::TimeWithZone, it is converted to Time without converting using timezone properly.
I know that business_time is timezone agnostic, but using rails .ago, .from_now helpers are pretty convenient.
Any feedback is appreciated :) !
At present, negative values are accepted but basically treated as zero. Compare:
irb> 1.hour.ago
=> Fri, 11 Sep 2015 11:41:00 BST +01:00
irb> (-10).days.since(1.hour.ago)
=> Tue, 01 Sep 2015 11:41:00 BST +01:00
irb> (-10).business_days.since(1.hour.ago)
=> Fri, 11 Sep 2015 11:41:00 BST +01:00
Maybe it's a bit daft to try to use negative business days or hours, but people like me will still try to do it! (Having negatives does simplify some interval-based calculations, and Rails does the sensible thing already.)
One option is to get (-x).business_FOO.since(y)
to call x.business_FOO.before(y)
. Even throwing an exception would be better than silently doing nothing.
ps. still a very handy gem - thanks!
Hello David,
looks great ! Would it be possible to have locale holiday conf files ?
config/locales/holidays_jp.yml or config/locales/holidays_us.yml ? (country-wise)
Is it possible to calculate the number of business days between two timestamps? Or the number of hours (for example between a Wednesday at noon and following Tuesday at 3pm)? Thanks!
0.7.4 was released with updated gems and several other changes, and with known incompatibilities with ruby 2.2.0. The point of 0.7.4 was to give a final dependency upgrade for people on older versions of ruby, so I could set a stage for a 0.8.0 release that can support ruby 2.2.0 and potentially drop support for 1.9.3 if needed .
to illustrate the incompatibility with 2.2.0, check out the project, use something like rbenv to set to ruby 2.2.0, and run the tests. They do not fail on ruby 2.1.5.
While this is not affecting my code, I noticed it while playing around while doing some brain storming on other stuff:
>> Time.now
=> 2016-03-31 11:15:08 -0400
>> 72.business_hours.ago
=> 2016-03-18 11:15:14 -0400
Using 3.business_days.ago works as expected.
>> 3.business_days.ago
=> 2016-03-28 11:15:21 -0400
Hi:
It's a fairly big design change for the gem so I'd like to throw the ideas out there and see how other people like it.
BusinessTime::Config.holidays
now is initialized as an empty array, but in theory we should have a hash of empty arrays with country codes as keys.
> BusinessTime::Config.holidays
> { US: ["2013-07-04", "2013-12-25"...],
CA: ["2013-07-01", "2013-12-25...]}
Thoughts?
One of the things our app needs to do is to reload the BusinessTime configuration to calculate differences for different companies.
We've had to resort to calling BusinessTime::Config.send(:reset)
in order to reset the configuration. I'm not sure why it's required, you'd think just over-writing the work_hours
config setting would do the trick, but it does not.
Here's a test script that proves the case (Ruby 1.9.3-p448, BusinessTime 0.7.2). The second business_days.after
call should pass, but it doesn't until we call reset
.
require 'business_time'
business_hours = {
mon: ['09:00', '17:00'],
tue: ['09:00', '17:00'],
wed: ['09:00', '17:00'],
thu: ['09:00', '17:00'],
fri: ['09:00', '17:00'],
}
open_24_hours = {
mon: ['00:00', '00:00'],
tue: ['00:00', '00:00'],
wed: ['00:00', '00:00'],
thu: ['00:00', '00:00'],
fri: ['00:00', '00:00'],
sat: ['00:00', '00:00'],
sun: ['00:00', '00:00'],
}
# April 1, 2014 is a Tuesday
start_date = Time.parse '1 April 2014 12:00pm'
BusinessTime::Config.work_hours = open_24_hours
if 15.business_days.after(start_date) == Time.parse('16 April 2014 12:00pm')
puts '.'
else
puts 'F'
end
BusinessTime::Config.work_hours = business_hours
if 15.business_days.after(start_date) == Time.parse('22 April 2014 12:00pm')
puts '.'
else
puts 'F'
end
BusinessTime::Config.send(:reset)
BusinessTime::Config.work_hours = business_hours
if 15.business_days.after(start_date) == Time.parse('22 April 2014 12:00pm')
puts '.'
else
puts 'F'
end
Hello -
Possibly something I'm just not understanding but I can not quite figure out the output when I run the following. I would expect the output to be 14400 (seconds).
Loading development environment (Rails 3.2.9)
irb(main):001:0> s = Time.now
=> 2012-11-23 11:52:37 -0500
irb(main):002:0> e = s + 4.hours
=> 2012-11-23 15:52:37 -0500
irb(main):003:0> s.business_time_until(e)
=> 442.6407476099994
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]
First of all, thanks for such a great gem!
I'm not really sure if this is an issue since it's something about the way we communicate. When we set up an option to set the business hours for a webapp and the user sets the opening and closing hours (let's say 10:00am and 5:30pm), he would expect his business to be open at 10:00am and stay open until the minute of 5:30pm runs out, so at 5:30:59 is open, but it's closed at 5:31:00.
However, that's not happening, if the closing hour is set to 5:30, the last second it will stay open is 5:29:59.
I know the configuration can be set to include seconds, however, how many people will use it? I think it should be a default until otherwise is stated.
What I ended up doing was monkeypatching the method and adding 1 minute:
module BusinessTime
module TimeExtensions
module ClassMethods
def end_of_workday(day)
end_of_workday = Time.parse(BusinessTime::Config.end_of_workday(day)) + 1.minute
change_business_time(day,end_of_workday.hour,end_of_workday.min,end_of_workday.sec)
end
end
end
end
Maybe the way to go would be via a config setting?
Open issues go back over a year. Last master was release about 10 months ago. If this is dead, that should be announced in the readme and people can either fix themselves or move on.
Seems dead to me.
After last update i've seen some weird result from 'after' method:
Sample:
[email protected] (main)> d = Date.parse('2015-05-29') => Fri, 29 May 2015 [email protected] (main)> 0.business_days.after(d) => Fri, 29 May 2015 [email protected] (main)> 1.business_days.after(d) => Mon, 01 Jun 2015 [email protected] (main)> d = Date.parse('2015-05-30') => Sat, 30 May 2015 [email protected] (main)> 1.business_days.after(d) => Tue, 02 Jun 2015 [email protected] (main)> 0.business_days.after(d) => Mon, 01 Jun 2015
Both results should not be Mon, 01 Jun 2015?
I want to get first business day after a date
We have an app that goes into multiple states/countries/provinces and each one has a different definition of a business day. Is there a way to properly support the different contexts needed?
Hi @bokmann,
I don't really expect this to sway you, but oh well, I'll try.
I just started using this gem at work. I found out what the gem name references, and it's not super professional and could be reasonably alienating (making people not very comfortable at work).
I know it's technically super annoying to change the gem name (maybe publish to two gem names on rubygems? another hassle, I know).
I say all this as a one-time very tired/thankless OSS dev/maintainer. You made this gem, I didn't, and I get that. If anything, please just give this idea a couple minutes of thought.
-Alan
Hello David,
Thanks for the great work! We are using this gem in our rails application to generate reports.
Now some of our reports need to be calculated on 24 hrs working day and some for 8 hrs. Users generate these reports parallely. Right now the changes we are making are reflecting across the application. We were unable to change business hrs on per request basis. Is there any way to change it on per request basis? So that each of our user have different business hrs configuration?
Thanks in advance!
Regards,
Abhishek
I just updated to version 0.7.0 now that business_time is thread safe.
I’m using it with rails 4.0.2, puma 2.7.1 and rubinius 2.2.3.
But now there’s a major problem, configuration is empty on every request made to the webserver.
Configuration is correctly loaded at startup but after that each thread has an empty configuration (as defined by the code at config.rb on line 13 of business time gem).
If I try with thin for example instead of puma, it seems to work as expected. So I think there’s a real bug in a true threaded environment (puma + rubinius).
Maybe Thread.current[:business_time_config]
should automatically load a previously loaded configuration instead of giving an empty one.
as written in the doc, BusinessTime::TimeExtensions#workday?
will return true
even if the time is outside of the normal business time.
which means the returning value of BusinessTime::BusinessDays#after
might be a time which is outside the normal business time.
I'm not against the spec of those API, but I think there are a large amount of people who would like to know the next business time after X business day.
To enable that, I think we'll need some new APIs for this gem, something like...
BusinessTime::TimeExtensions#business_time?
true
if either of BusinessTime::TimeExtensions#before_business_hours?
or #after_business_hours?
returns true
BusinessTime::TimeExtensions#next_if_not_business_time
wdyt? :O
Ran in to an issue with calling business_days.after() on a date that started on the weekend. Found the bug #14 that has a fix for it and shows it was fixed over a year ago. Verified that the latest version of business_time I see as a gem is 0.6.1, but it still has the broken code in it.
Could you do a new release so the latest gem has the latest code please?
Hi! First of all, great project!
I just stumbled upon it, and I was wondering if it is possible to create multiple instances of the base class with different business hours.
Something like this:
bt = BusinessTime.new(work_hours: {mon: ["9:00","17:00"], tue: ["10:00","15:00"]})
friday = Date.parse("December 24, 2010")
monday = Date.parse("December 27, 2010")
bt.business_days_until(friday, monday)
My use case is that in my startup we manage beauty salons which have many different opening times, with professionals that may have different working hours.
how would i use this gem with different geographic zones that have different holidays? is there a way that is already built in?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.