added to_date and to_time methods to Redistat::Date

This commit is contained in:
2010-07-19 02:25:29 +03:00
parent f1e3f20c88
commit 5bd2301102

View File

@@ -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)