lib/almanack/event.rb in almanack-1.1.2 vs lib/almanack/event.rb in almanack-1.1.3.rc1

- old
+ new

@@ -1,16 +1,22 @@ require 'ostruct' module Almanack class Event < OpenStruct def formatted_date - formatted = "#{formatted_day(start_time)} at #{formatted_time(start_time)}" + warn "formatted_date is deprecated, please use formatted_duration instead" + formatted_duration + end + def formatted_duration + formatted = "#{formatted_day(start_time)}" + formatted << " at #{formatted_time(start_time)}" unless start_time.is_a?(Date) + if end_time - formatted << " to " + formatted << " to " unless is_date_ending_on_same_day? formatted << "#{formatted_day(end_time)} at " unless ends_on_same_day? - formatted << formatted_time(end_time) + formatted << formatted_time(end_time) unless end_time.is_a?(Date) end formatted end @@ -75,9 +81,13 @@ newer_value elsif fallback_value warn "Deprecated event property #{older_method} is set; set #{newer_method} property instead" fallback_value end + end + + def is_date_ending_on_same_day? + end_time.is_a?(Date) && ends_on_same_day? end def ends_on_same_day? [start_time.year, start_time.yday] == [end_time.year, end_time.yday] end