Permalink
Browse files

Time.at takes optional millisecond argument to be consistent with the…

… original method. Fixes #34
  • Loading branch information...
1 parent 9a34c70 commit 431dcabe92fd881d9a35761a01e12825c6c9cc84 @olbrich committed Feb 2, 2012
Showing with 6 additions and 3 deletions.
  1. +5 −3 lib/ruby_units/time.rb
  2. +1 −0 spec/ruby-units/time_spec.rb
@@ -11,13 +11,15 @@ class << self
# Convert a duration to a Time value by considering the duration to be the number of seconds since the
# epoch
+ # @param [Time] arg
+ # @param [Integer] ms
# @return [Unit, Time]
- def self.at(arg)
+ def self.at(arg,ms=0)
case arg
when Unit
- unit_time_at(arg.convert_to("s").scalar)
+ unit_time_at(arg.convert_to("s").scalar, ms)
else
- unit_time_at(arg)
+ unit_time_at(arg, ms)
end
end
@@ -8,6 +8,7 @@
context ".at" do
subject { Date.new(2011,4,1).to_unit }
specify { Time.at(subject - Date.new(1970,1,1)).strftime("%D %T").should == "03/31/11 20:00:00"}
+ specify { Time.at(subject - Date.new(1970,1,1), 500).usec.should == 500}
end
context ".in" do

0 comments on commit 431dcab

Please sign in to comment.