Created
May 27, 2014 17:02
-
-
Save bear454/82b8819f8b3a02391d9d to your computer and use it in GitHub Desktop.
conference date string refactor
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
def conference_date_string(conf) | |
startstr = "Unknown - " | |
endstr = "Unknown" | |
# When the conference in the same motn | |
if conf.start_date.month == conf.end_date.month and conf.start_date.year == conf.end_date.year | |
startstr = conf.start_date.strftime("%B %d - ") | |
endstr = conf.end_date.strftime("%d, %Y") | |
elsif conf.start_date.month != conf.end_date.month && conf.start_date.year == conf.end_date.year | |
startstr = conf.start_date.strftime("%B %d - ") | |
endstr = conf.end_date.strftime("%B %d, %Y") | |
else | |
startstr = conf.start_date.strftime("%B %d, %Y - ") | |
endstr = conf.end_date.strftime("%B %d, %Y") | |
end | |
result = startstr + endstr | |
result | |
end |
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
def conference_date_string(conf) | |
date_string(conf.start_date, conf.end_date) | |
end | |
def date_string(start_date, end_date) | |
startstr = 'Unknown - ' | |
endstr = 'Unknown' | |
# When the conference in the same motn | |
if start_date.month == end_date.month && start_date.year == end_date.year | |
startstr = start_date.strftime('%B %d - ') | |
endstr = end_date.strftime('%d, %Y') | |
elsif start_date.month != end_date.month && start_date.year == end_date.year | |
startstr = start_date.strftime('%B %d - ') | |
endstr = end_date.strftime('%B %d, %Y') | |
else | |
startstr = start_date.strftime('%B %d, %Y - ') | |
endstr = end_date.strftime('%B %d, %Y') | |
end | |
result = startstr + endstr | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment