Skip to content

Instantly share code, notes, and snippets.

@bear454
Created May 27, 2014 17:02
Show Gist options
  • Save bear454/82b8819f8b3a02391d9d to your computer and use it in GitHub Desktop.
Save bear454/82b8819f8b3a02391d9d to your computer and use it in GitHub Desktop.
conference date string refactor
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
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