app/models/events/event_staff_position_shift.rb
# Returns a human-readable bit of text describing the start and end times of this shift. Uses the same options as
# Event#time_detail.
Returns a human-readable bit of text describing the start and end times of this shift. Uses the same options as
Event#time_detail.
Returns a human - readable bit of text describing the start and end times of this shift . Uses the same options as Event#time_detail .
def time_detail(options = {})
    options = { :use_words => true, :date_format => :date_with_day_of_week, :time_format => :time12 }.merge(options)
    separator = options[:use_words] ? { :to => " to", :from => " from", :at => " at" } : { :to => " -", :from => "", :at => "" }
    _start_date = start_time.to_date.to_s(options[:date_format]).strip if start_time
    _start_date = "Today" if start_time.to_date == Time.now.to_date && start_time
    _start_date = "Tomorrow" if start_time.to_date == 1.day.from_now.to_date && start_time
    _start_time = start_time.to_time.to_s(options[:time_format]).strip if start_time
    _end_date = end_time.to_date.to_s(options[:date_format]).strip if end_time
    _end_date = "today" if end_time && end_time.to_date == Time.now.to_date
    _end_date = "tomorrow" if end_time && end_time.to_date == 1.day.from_now.to_date
    _end_time = end_time.to_time.to_s(options[:time_format]).strip if end_time
    return "#{_start_date}" if options[:date_only] && (end_time.nil? || start_time.to_date == end_time.to_date)
    return "#{_start_time}" if options[:time_only] && (end_time.nil?)
    return "#{_start_time}#{separator[:to]} #{_end_time}" if options[:time_only] && !end_time.nil? && start_time.to_date == end_time.to_date
    return "#{_start_date}#{separator[:at]} #{_start_time}" if end_time.nil?
    return "#{_start_date}#{separator[:from]} #{_start_time}#{separator[:to]} #{_end_time}" if start_time.to_date == end_time.to_date
    return "#{_start_date}#{separator[:at]} #{_start_time}#{separator[:to]} #{_end_date}#{separator[:at]} #{_end_time}"
  end
def time_detail ( options = { } ) options = { :use_words => true , :date_format => :date_with_day_of_week , :time_format => :time12 } . merge ( options ) separator = options [ :use_words ] ? { :to => " to" , :from => " from" , :at => " at" } : { :to => " -" , :from => "" , :at => "" } _start_date = start_time . to_date . to_s ( options [ :date_format ] ) . strip if start_time _start_date = "Today" if start_time . to_date == Time . now . to_date && start_time _start_date = "Tomorrow" if start_time . to_date == 1 . day . from_now . to_date && start_time _start_time = start_time . to_time . to_s ( options [ :time_format ] ) . strip if start_time _end_date = end_time . to_date . to_s ( options [ :date_format ] ) . strip if end_time _end_date = "today" if end_time && end_time . to_date == Time . now . to_date _end_date = "tomorrow" if end_time && end_time . to_date == 1 . day . from_now . to_date _end_time = end_time . to_time . to_s ( options [ :time_format ] ) . strip if end_time return "#{_start_date}" if options [ :date_only ] && ( end_time . nil? || start_time . to_date == end_time . to_date ) return "#{_start_time}" if options [ :time_only ] && ( end_time . nil? ) return "#{_start_time}#{separator[:to]} #{_end_time}" if options [ :time_only ] && ! end_time . nil? && start_time . to_date == end_time . to_date return "#{_start_date}#{separator[:at]} #{_start_time}" if end_time . nil? return "#{_start_date}#{separator[:from]} #{_start_time}#{separator[:to]} #{_end_time}" if start_time . to_date == end_time . to_date return "#{_start_date}#{separator[:at]} #{_start_time}#{separator[:to]} #{_end_date}#{separator[:at]} #{_end_time}" end
Returns a human-readable bit of text describing the start and end times of this shift.
Returns a human - readable bit of text describing the start and end times of this shift .
options