Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/business_time/business_days.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def calculate_after(time, days, options={})
time = Time.beginning_of_workday(time)
end
while days > 0 || !time.workday?(options)
days -= 1 if time.workday?(options)
time += 1.day
days -= 1 if time.workday?(options)
end
# If we have a Time or DateTime object, we can roll_forward to the
# beginning of the next business day
Expand Down
15 changes: 4 additions & 11 deletions test/test_business_days.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,10 @@
assert_equal expected, monday_afternoon
end

it "should move to tuesday if we add one business day during a weekend" do
it "should move to Monday if we add one business day during a weekend" do
saturday = Time.parse("April 10th, 2010, 11:00 am")
later = 1.business_days.after(saturday)
expected = Time.parse("April 13th, 2010, 9:00 am")
assert_equal expected, later
end

it "should move to tuesday if we add one business day during a weekend outside normal business hours" do
saturday = Time.parse("April 10th, 2010, 11:55 pm")
later = 1.business_days.after(saturday)
expected = Time.parse("April 13th, 2010, 9:00 am")
expected = Time.parse("April 12th, 2010, 9:00 am")
assert_equal expected, later
end

Expand Down Expand Up @@ -242,10 +235,10 @@
assert_equal expected, later
end

it "should move to tuesday if we subtract one negative business day during a weekend" do
it "should move to Monday if we subtract one negative business day during a weekend" do
saturday = Time.parse("April 10th, 2010, 11:00 am")
later = -1.business_days.before(saturday)
expected = Time.parse("April 13th, 2010, 09:00 am")
expected = Time.parse("April 12th, 2010, 09:00 am")
assert_equal expected, later
end

Expand Down
8 changes: 4 additions & 4 deletions test/test_business_days_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
assert_equal expected, monday_afternoon
end

it "move to tuesday if we add one business day during a weekend" do
it "move to Monday if we add one business day during a weekend" do
saturday = Date.parse("April 10th, 2010")
later = 1.business_days.after(saturday)
expected = Date.parse("April 13th, 2010")
expected = Date.parse("April 12th, 2010")
assert_equal expected, later
end

Expand Down Expand Up @@ -146,10 +146,10 @@
assert_equal expected, before
end

it "move to tuesday if we subtract one negative business day during a weekend" do
it "move to Monday if we subtract one negative business day during a weekend" do
saturday = Date.parse("April 10th, 2010")
after = -1.business_days.before(saturday)
expected = Date.parse("April 13th, 2010")
expected = Date.parse("April 12th, 2010")
assert_equal expected, after
end

Expand Down