Skip to content

Commit

Permalink
Extract Utils#days_in_month to delegate to Time
Browse files Browse the repository at this point in the history
  • Loading branch information
rossta committed Feb 20, 2016
1 parent 16634cd commit 1a7a0f9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/montrose/rule/day_of_month.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def include?(time)

# matches days specified at negative numbers
def included_from_end_of_month?(time)
month_days = Time.days_in_month(time.month, time.year) # given by activesupport
month_days = ::Montrose::Utils.days_in_month(time.month, time.year) # given by activesupport
@days.any? { |d| month_days + d + 1 == time.mday }
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/montrose/rule/day_of_year.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def included_from_end_of_month?(time)
# If no year is specified, it will use the current year.
# https://github.com/rails/rails/pull/22244
def days_in_year(year)
Time.days_in_month(2, year) + 337
::Montrose::Utils.days_in_month(2, year) + 337
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/montrose/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,9 @@ def day_number!(name)
day_number(name) or fail ConfigurationError,
"Did not recognize day #{name}, must be one of #{DAYS.inspect}"
end

def days_in_month(*args)
::Time.days_in_month(*args)
end
end
end

0 comments on commit 1a7a0f9

Please sign in to comment.