class EventDb::Model::Event
Public Instance Methods
current_day( today=Date.today )
click to toggle source
# File lib/eventdb/models.rb, line 16 def current_day( today=Date.today ) today.mjd - start_date.mjd + 1 # calculate current event day (1,2,3,etc.) end
Also aliased as: cur_day
date_fmt( fmt='long' )
click to toggle source
# File lib/eventdb/models.rb, line 27 def date_fmt( fmt='long' ) # date pretty printed (pre-formatted) as string (with weeknames) ## note: wday - (0-6, Sunday is zero). if days == 1 buf = '' if fmt == 'long' buf << Date::ABBR_DAYNAMES[start_date.wday] buf << ' ' end buf << Date::ABBR_MONTHNAMES[start_date.month] buf << '/' buf << start_date.day.to_s elsif days == 2 buf = '' if fmt == 'long' buf << Date::ABBR_DAYNAMES[start_date.wday] buf << '+' buf << Date::ABBR_DAYNAMES[end_date.wday] buf << ' ' end buf << Date::ABBR_MONTHNAMES[start_date.month] buf << '/' buf << start_date.day.to_s buf << '+' if start_date.month != end_date.month buf << Date::ABBR_MONTHNAMES[end_date.month] buf << '/' end buf << end_date.day.to_s else ## assume multi day buf = '' if fmt == 'long' buf << Date::ABBR_DAYNAMES[start_date.wday] buf << '-' buf << Date::ABBR_DAYNAMES[end_date.wday] buf << ' ' end buf << Date::ABBR_MONTHNAMES[start_date.month] buf << '/' buf << start_date.day.to_s buf << '-' if start_date.month != end_date.month buf << Date::ABBR_MONTHNAMES[end_date.month] buf << '/' end buf << end_date.day.to_s end buf end
diff_days( today=Date.today )
click to toggle source
# File lib/eventdb/models.rb, line 21 def diff_days( today=Date.today ) start_date.mjd - today.mjd # note: mjd == Modified Julian Day Number end