Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Upcoming

## 3.2.0 - Nov 3, 2026

- Advance `ActiveSupport::TimeWithZone`s whole days across DST boundaries #339

## 3.1.0 - Sept 28, 2026

- Fix `business_days_between` not counting extra working dates in full weeks #34 - thanks @anatoliliotych!
Expand Down
8 changes: 7 additions & 1 deletion lib/business/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,13 @@ def business_days_between(date1, date2)
end

def day_interval_for(date)
date.is_a?(Date) ? 1 : 3600 * 24
if date.is_a?(Date)
1
elsif defined?(ActiveSupport::TimeWithZone) && date.is_a?(ActiveSupport::TimeWithZone)
1.day
else
3600 * 24
end
end

# Internal method for assigning working days from a calendar config.
Expand Down
2 changes: 1 addition & 1 deletion lib/business/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Business
VERSION = "3.1.0"
VERSION = "3.2.0"
end
14 changes: 14 additions & 0 deletions spec/business/calendar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1049,4 +1049,18 @@

it_behaves_like "common"
end

context "(using TimeWithZone objects)" do
before do
stub_const("ActiveSupport::TimeWithZone", Class.new(Time))
Integer.define_method(:day) { self * 60 * 60 * 24 }
end

after { Integer.remove_method(:day) }

let(:date_class) { ActiveSupport::TimeWithZone }
let(:day_interval) { 1.day }

it_behaves_like "common"
end
end
Loading