Skip to content

Instantly share code, notes, and snippets.

@omnikron
Last active December 16, 2015 03:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omnikron/5371908 to your computer and use it in GitHub Desktop.
Save omnikron/5371908 to your computer and use it in GitHub Desktop.
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