Skip to content

Add time trimmer helpers #3

@cupakromer

Description

@cupakromer

Using some of these in other projects. Would be nice to have them added. Not to keen on the naming just yet, so throwing some examples below:

time = Time.now
# => 2013-06-20 14:12:30 -0400
# => time.usec => 124634

time_truncate(time, :day)
# => 2013-06-20 14:12:30 -0400

time_truncate(time, :hour)
# => 2013-06-20 14:00:00 -0400

time_strip(time, :minute)
# => 2013-06-20 14:12:00 -0400

time_trim(time, :second)
# => 2013-06-20 14:12:00 -0400
# => time.usec => 0

See rspec/rspec-mocks#318 for a similar discussion.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions