diff --git a/lib/ruby_units/time.rb b/lib/ruby_units/time.rb index 9ac59f5d..f3100078 100644 --- a/lib/ruby_units/time.rb +++ b/lib/ruby_units/time.rb @@ -16,6 +16,8 @@ class << self # @return [Unit, Time] def self.at(arg,ms=0) case arg + when Time + unit_time_at(arg) when Unit unit_time_at(arg.convert_to("s").scalar, ms) else diff --git a/spec/ruby-units/time_spec.rb b/spec/ruby-units/time_spec.rb index 019cd993..96492874 100644 --- a/spec/ruby-units/time_spec.rb +++ b/spec/ruby-units/time_spec.rb @@ -8,6 +8,7 @@ context ".at" do subject { Date.new(2011,4,1).to_unit } + specify { Time.at(Time.at(0)).utc.strftime("%D %T").should == "01/01/70 00:00:00" } specify { Time.at(subject - Date.new(1970,1,1)).getutc.strftime("%D %T").should == "04/01/11 00:00:00"} specify { Time.at(subject - Date.new(1970,1,1), 500).usec.should == 500} end