Comments (2)
This looks right to me if you assume 8 hours per business day gives 9 business days for 72 hours.
from business_time.
This is an interesting edge case, relies on understanding the difference between business hours and business days, and my mind could be changed on this behavior. It might clear up some of the other open issues as well, but it is a change in semantics that might affect other people using them gem.
Today is a Saturday
Time.now
=> 2017-04-01 14:20:35 -0400
Three business days ago counts back on the date, but leaves the time the same:
3.business_days.ago
=> 2017-03-28 14:20:39 -0400
counting back by hours starts counting from the last worked business hour.
24.business_hours.ago
=> 2017-03-29 09:00:00 -0400
Notice the slight time difference is within the day/hour, and causes the day to be different between these two edge cases. I believe the day is right when the unit you care about is days, but the hour is right if you care about hours. Here's why:
The difference is best illustrated by considering edge cases. imagine a Friday where work stopped at 5pm. It's now 5:01pm on that very same Friday. When is one work hour ago? seems like 4pm to me. When is one work day from now? 9am today doesn't feel right for the colloquial use of this term.
The difference comes down to the answer to the question, "Do events that happen between 5pm on one business day and 9am the next business day, count as happening at 5pm that day or 9am the next day? Your environment may make a different assumption then the one in the environment where this gem was designed. Perhaps that needs to be a configuration option.
from business_time.
Related Issues (20)
- business_time_until doesn't account for holidays when called on Time objects HOT 1
- initiate business_time instead of global definitions HOT 3
- Short days before holiday HOT 1
- Still finding problems next business day for mondays HOT 3
- factory time vs. office time HOT 2
- Business day calculation wrong for weekends HOT 1
- Request for API for 'next business Friday' etc
- Wrong Result or unexpected not-business day ? HOT 1
- Business day calculations off when starting with a non-workday HOT 1
- business_days.after weird behaviour when not in workday and out of business hours. HOT 2
- Support Ruby 3.0.0 HOT 2
- No CHANGELOG for newer versions HOT 1
- [Bug] business_days.after inconsistencies HOT 3
- during_business_hours? returning nil since 0.10.0 HOT 3
- [Bug] Concurrency issues HOT 6
- rubocop-users: Rubocop-rails autocorrection mistake
- Support Time gem version >= 0.2.0 HOT 1
- Consider dropping external deps: sorted_set and rbtree dependencies? HOT 4
- The method from_now of Class: BusinessTime::BusinessDays returns different results under the same context HOT 6
- Allow business hours that cross midnight HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from business_time.