Convert TimeOfDay values to UTC.

This commit is contained in:
Lars Haugseth
2015-10-03 16:34:27 +02:00
parent a93b937d14
commit 4b7b03f8a1
2 changed files with 10 additions and 12 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ module Crono
def description def description
desc = "every #{@period.inspect}" desc = "every #{@period.inspect}"
desc += " between #{@interval.from} and #{@interval.to}" if @interval desc += " between #{@interval.from} and #{@interval.to} UTC" if @interval
desc += format(' at %.2i:%.2i', @at_hour, @at_min) if @at_hour && @at_min desc += format(' at %.2i:%.2i', @at_hour, @at_min) if @at_hour && @at_min
desc += " on #{DAYS[@on].capitalize}" if @on desc += " on #{DAYS[@on].capitalize}" if @on
desc desc
+5 -7
View File
@@ -6,17 +6,15 @@ module Crono
attr_accessor :hour, :min attr_accessor :hour, :min
def self.parse(value) def self.parse(value)
time =
case value case value
when String when String then Time.parse(value).utc
time = Time.parse(value) when Hash then Time.now.change(value).utc
new time.hour, time.min when Time then value.utc
when Hash
new value[:hour], value[:min]
when Time
new value.hour, value.min
else else
fail "Unknown TimeOfDay format: #{value.inspect}" fail "Unknown TimeOfDay format: #{value.inspect}"
end end
new time.hour, time.min
end end
def initialize(hour, min) def initialize(hour, min)