bokmann / business_time

Support for doing time math in business hours and days
MIT License
1.27k stars 215 forks source link

question about from_now #140

Closed loicginoux closed 7 years ago

loicginoux commented 8 years ago

I have a behaviour that seems weird:

2.3.1 :010 > Date.today
Thu, 29 Sep 2016

2.3.1 :011 > 1.business_days.after(Date.today)
Fri, 30 Sep 2016

2.3.1 :012 > 1.business_days.from_now
Mon, 03 Oct 2016 09:00:00 CEST +02:00

2.3.1 :013 > BusinessTime::Config.work_week
[
    [0] "mon",
    [1] "tue",
    [2] "wed",
    [3] "thu",
    [4] "fri"
]

I would have expected 1.business_days.from_now.to_date == 1.business_days.after(Date.today) is that the expected behaviour ?

the-bass commented 7 years ago

I'd say this behavior is totally ok if, by the time you did > 1.business_days.from_now, the working day was already over (by default, a working day ends at 5 pm, if I remember correctly). Note, that 1.business_days.from_now uses the current time as the reference, while 1.business_days.after(Date.today) uses the current date.

loicginoux commented 7 years ago

If I see the time I created this issue (~7pm) it looks like it falls into this case, I didn't think about this work hours... So I'll just close the ticket. Thanks.