rearrange helper functions
This commit is contained in:
parent
f63259f187
commit
5b1a730e19
5 changed files with 30 additions and 71 deletions
|
|
@ -2,41 +2,6 @@ module DateTimeHelper
|
|||
##
|
||||
# Includes functions related to date or time manipulations
|
||||
##
|
||||
##
|
||||
# Returns a string build from the start and end date of the given conference.
|
||||
#
|
||||
# If the conference is only one day long
|
||||
# * %B %d %Y (January 17 2014)
|
||||
# If the conference starts and ends in the same month and year
|
||||
# * %B %d - %d, %Y (January 17 - 21 2014)
|
||||
# If the conference ends in another month but in the same year
|
||||
# * %B %d - %B %d, %Y (January 31 - February 02 2014)
|
||||
# All other cases
|
||||
# * %B %d, %Y - %B %d, %Y (December 30, 2013 - January 02, 2014)
|
||||
def date_string(start_date, end_date)
|
||||
startstr = 'Unknown - '
|
||||
endstr = 'Unknown'
|
||||
# When the conference is in the same month
|
||||
if start_date.month == end_date.month && start_date.year == end_date.year
|
||||
if start_date.day == end_date.day
|
||||
startstr = start_date.strftime('%B %d')
|
||||
endstr = end_date.strftime(' %Y')
|
||||
else
|
||||
startstr = start_date.strftime('%B %d - ')
|
||||
endstr = end_date.strftime('%d, %Y')
|
||||
end
|
||||
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
|
||||
|
||||
##
|
||||
# Gets an EventType object, and returns its length in timestamp format (HH:MM)
|
||||
# ====Gets
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue