mirror of
https://github.com/jimeh/redistat.git
synced 2026-02-19 13:26:39 +00:00
added integer input/output support to
Redistat::Date so Unix timestamps can be used directly
This commit is contained in:
@@ -17,6 +17,14 @@ describe Redistat::Date do
|
||||
end
|
||||
end
|
||||
|
||||
it "should initialize from Fixnum object (UNIX Timestamp)" do
|
||||
now = Time.now.to_i
|
||||
time = Time.at(now)
|
||||
[Redistat::Date.new(now), now.to_rs].each do |rdate|
|
||||
[:year, :month, :day, :hour, :min, :sec].each { |k| rdate.send(k).should == time.send(k) }
|
||||
end
|
||||
end
|
||||
|
||||
it "should initialize from String object" do
|
||||
now = Time.now
|
||||
rdate = Redistat::Date.new(now.to_s)
|
||||
@@ -35,6 +43,12 @@ describe Redistat::Date do
|
||||
rdate.to_date.to_s.should == today.to_s
|
||||
end
|
||||
|
||||
it "should convert to Fixnum object (UNIX Timestamp)" do
|
||||
now = Time.now
|
||||
rdate = Redistat::Date.new(now)
|
||||
rdate.to_i.should == now.to_i
|
||||
end
|
||||
|
||||
it "should convert to string with correct depths" do
|
||||
today = Date.today
|
||||
now = Time.now
|
||||
|
||||
Reference in New Issue
Block a user