-
-
Save pkieltyka/157313 to your computer and use it in GitHub Desktop.
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
def day_with_suffix(d = Time.now) | |
current_day = d.strftime("%d") | |
day_number = current_day.split(//).last | |
suffix = case day_number | |
when 1 | |
"st" | |
when 2 | |
"nd" | |
when 3 | |
"rd" | |
else | |
"th" | |
end | |
return "#{current_day}#{suffix}" | |
end | |
puts day_with_suffix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment