From 5bd23011027bde7f8e8fd6b6391e3c609bb99823 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Mon, 19 Jul 2010 02:25:29 +0300 Subject: [PATCH] added to_date and to_time methods to Redistat::Date --- lib/redistat/date.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/redistat/date.rb b/lib/redistat/date.rb index ce8b335..4214364 100644 --- a/lib/redistat/date.rb +++ b/lib/redistat/date.rb @@ -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)