lib/timeframe.rb in timeframe-0.1.1 vs lib/timeframe.rb in timeframe-0.2.0

- old
+ new

@@ -74,11 +74,11 @@ when ::Hash from_hash input when ::String str = input.strip if str.start_with?('{') - from_hash MultiJson.decode(str) + from_hash MultiJson.load(str) elsif input =~ /\A\d\d\d\d\z/ from_year input else from_iso8601 str end @@ -277,14 +277,14 @@ def last_year self.class.new((start_date - 1.year), (end_date - 1.year)) end def to_json(*) - %({"startDate":"#{start_date.iso8601}","endDate":"#{end_date.iso8601}"}) + iso8601 end def as_json(*) - { :startDate => start_date.iso8601, :endDate => end_date.iso8601 } + iso8601 end # An ISO 8601 "time interval" like YYYY-MM-DD/YYYY-MM-DD def iso8601 "#{start_date.iso8601}/#{end_date.iso8601}"