lib/green-button-data/parser/interval.rb in green-button-data-0.2.1 vs lib/green-button-data/parser/interval.rb in green-button-data-0.3.0
- old
+ new
@@ -10,15 +10,19 @@
element :start, class: Integer do |t|
normalize_epoch t
end
- def starts_at
- Time.at(normalize_epoch(@start)).utc.to_datetime
+ def starts_at(kwargs = {})
+ epoch_to_time @start, kwargs
end
- def ends_at
- Time.at(normalize_epoch(@start + @duration)).utc.to_datetime
+ def ends_at(kwargs = {})
+ epoch_to_time @start + @duration, kwargs
+ end
+
+ def to_s
+ "#{starts_at} - #{ends_at}"
end
# Standard ESPI namespacing
element :'espi:duration', class: Integer, as: :duration
element :'espi:start', class: Integer, as: :start