Forked from sirramongabriel/date_comparison_fail.rb
Last active
December 16, 2019 15:17
-
-
Save CodingFu/8f8b7de9464f567507f2f143dd560c5a to your computer and use it in GitHub Desktop.
This file contains 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
trial_start_date = current_provider.created_at | |
if free_trial_completed?(trial_start_date) | |
current_provider.update(in_free_trial: false) | |
elsif in_sixty_day_trial?(trial_start_date) | |
current_provider.update(in_free_trial: true) | |
elsif in_thirty_day_trial?(trial_start_date) | |
current_provider.update(in_free_trial: true) | |
end | |
def in_thirty_day_trial?(date_time) | |
date = date_time.to_date | |
puts "created_at: #{date} 31.days.ago: #{31.days.ago}" | |
date > 31.days.ago | |
end | |
def in_sixty_day_trial?(date_time) | |
date = date_time.to_date | |
puts "created_at: #{date} 30.days.ago: #{30.days.ago} 61.days.ago: #{61.days.ago}" | |
date < 31.days.ago && date > 61.days.ago | |
end | |
def free_trial_completed?(date_time) | |
date = date_time.to_date | |
puts "created_at: #{date} 60.days.ago: #{60.days.ago} " | |
date < 60.days.ago | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment