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

View File

@@ -31,7 +31,7 @@ module Crono
def description
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 += " on #{DAYS[@on].capitalize}" if @on
desc

View File

@@ -6,17 +6,15 @@ module Crono
attr_accessor :hour, :min
def self.parse(value)
case value
when String
time = Time.parse(value)
new time.hour, time.min
when Hash
new value[:hour], value[:min]
when Time
new value.hour, value.min
else
fail "Unknown TimeOfDay format: #{value.inspect}"
end
time =
case value
when String then Time.parse(value).utc
when Hash then Time.now.change(value).utc
when Time then value.utc
else
fail "Unknown TimeOfDay format: #{value.inspect}"
end
new time.hour, time.min
end
def initialize(hour, min)