mirror of
https://github.com/plashchynski/crono.git
synced 2026-06-12 09:44:27 +02:00
Convert TimeOfDay values to UTC.
This commit is contained in:
+1
-1
@@ -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
|
||||||
|
|||||||
@@ -6,17 +6,15 @@ module Crono
|
|||||||
attr_accessor :hour, :min
|
attr_accessor :hour, :min
|
||||||
|
|
||||||
def self.parse(value)
|
def self.parse(value)
|
||||||
case value
|
time =
|
||||||
when String
|
case value
|
||||||
time = Time.parse(value)
|
when String then Time.parse(value).utc
|
||||||
new time.hour, time.min
|
when Hash then Time.now.change(value).utc
|
||||||
when Hash
|
when Time then value.utc
|
||||||
new value[:hour], value[:min]
|
else
|
||||||
when Time
|
fail "Unknown TimeOfDay format: #{value.inspect}"
|
||||||
new value.hour, value.min
|
end
|
||||||
else
|
new time.hour, time.min
|
||||||
fail "Unknown TimeOfDay format: #{value.inspect}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(hour, min)
|
def initialize(hour, min)
|
||||||
|
|||||||
Reference in New Issue
Block a user