mirror of
https://github.com/plashchynski/crono.git
synced 2026-03-24 10:21:54 +01:00
Convert TimeOfDay values to UTC.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user