mirror of
https://github.com/jimeh/redistat.git
synced 2026-02-19 13:26:39 +00:00
added to_date and to_time methods to Redistat::Date
This commit is contained in:
@@ -24,14 +24,22 @@ module Redistat
|
||||
end
|
||||
end
|
||||
|
||||
def to_time
|
||||
::Time.local(@year, @month, @day, @hour, @min, @sec)
|
||||
end
|
||||
|
||||
def from_date(input)
|
||||
[:year, :month, :day].each do |k|
|
||||
self.send("#{k}=", input.send(k))
|
||||
end
|
||||
end
|
||||
|
||||
def to_date
|
||||
::Date.civil(@year, @month, @day)
|
||||
end
|
||||
|
||||
def from_string(input)
|
||||
from_time(Time.parse(input))
|
||||
from_time(::Time.parse(input))
|
||||
end
|
||||
|
||||
def to_s(depth = :sec)
|
||||
|
||||
Reference in New Issue
Block a user