diff --git a/app/models/event_news.rb b/app/models/event_news.rb index 9ded48a..49e12cd 100644 --- a/app/models/event_news.rb +++ b/app/models/event_news.rb @@ -174,11 +174,21 @@ class EventNews parse_format = self.date_parse_format if s.to_date == e.to_date parse_format_arr = parse_format.split(/(%d %a|%d) /) - parse_format_arr = parse_format_arr[0..-2].join(""), parse_format_arr[-1] + if parse_format_arr.count > 1 + parse_format_arr = parse_format_arr[0..-2].join(""), parse_format_arr[-1] + end date_str = custom_strftime(s, parse_format_arr[0]) - s_time = s.strftime(parse_format_arr[1]) - e_time = e.strftime(parse_format_arr[1]) - "#{date_str} #{s_time} ~ #{e_time}" + s_time = s.strftime(parse_format_arr[1].to_s) + e_time = e.strftime(parse_format_arr[1].to_s) + if e_time.present? + if s_time != e_time + "#{date_str} #{s_time} ~ #{e_time}" + else + "#{date_str} #{s_time}" + end + else + date_str + end else custom_strftime(s, self.date_parse_format) + " ~ " + custom_strftime(e, self.date_parse_format) end