Create a gist now

Instantly share code, notes, and snippets.

@omnikron /Bill.rb
Last active Dec 16, 2015

What would you like to do?
For recurring billing.
# Calculates billable day-of-month numbers at the end
# of a month with fewer than 31 days.
#
# eg. billable_days Date.new(2012, 02, 29) => 29, 30, 31
#
def billable_days(date = Date.today)
if date.day == date.end_of_month.day
(date.day..31)
else
date.day
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment