Skip to content

Redefinition of Time.at doesn't handle all possible arguments; breaks Timecop #69

@kranzky

Description

@kranzky

Calling Time.at(Time.now) is legal in vanilla ruby (this is from the docs):

at( aTime ) => time click to toggle source
at( seconds [, microseconds] ) => time

The redefinition in ruby-units breaks this, which causes Timecop to fail for us. The fix might look like this:

  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
      unit_time_at(arg, ms)
    end
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions