Last active
December 16, 2015 03:39
-
-
Save omnikron/5371908 to your computer and use it in GitHub Desktop.
For recurring billing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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