Skip to content

Instantly share code, notes, and snippets.

@stengland
Created May 8, 2013 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stengland/5539782 to your computer and use it in GitHub Desktop.
Save stengland/5539782 to your computer and use it in GitHub Desktop.
def months_til_renewal
months = 0
date_to_check = Date.current
while(date_to_check < current_period_ends_at.to_date) do
date_to_check = date_to_check.next_month
months += 1
end
months
end
@sstarr
Copy link

sstarr commented May 8, 2013

def months_til_renewal
  (current_period_ends_at.year * 12 + current_period_ends_at.month) - (Date.current.year * 12 + Date.current.month)
end

@theozaurus
Copy link

def months_til_renewal
   ((current_period_ends_at - Time.now) / 1.month).ceil
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment