Skip to content

Instantly share code, notes, and snippets.

@JKring
Created June 27, 2013 23:02
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 JKring/5881168 to your computer and use it in GitHub Desktop.
Save JKring/5881168 to your computer and use it in GitHub Desktop.
payday logic
def is_payday?(t)
return true if (t.end_of_month.saturday? || t.end_of_month.sunday?) && t.friday?
return true if [13, 14].include?(t.day) && t.friday?
return true if (t.end_of_month == t.midnight || t.day == 15) && !(t.saturday? || t.sunday?)
return false
end
@time = DateTime.now
100.times do |i|
t = @time.advance(days: i)
puts t.strftime("%D #{ is_payday?(t) }")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment