Skip to content
Round Time in Ruby with Ease
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bench
bin
lib
test
.gitignore
.rubocop.yml
.travis.yml
CODE_OF_CONDUCT.md
Gemfile
LICENSE.txt
README.md
Rakefile
time_rounder.gemspec

README.md

TimeRounder

TimeRounder is a gem born to solve a problem, which is to round time, without all the complex math. TimeRounder defeats all the complex math used to round time, by using logic.

Note: Support for Ruby 1.9.3 & 2.0.x has been dropped.

Installation

Add this line to your application's Gemfile:

gem 'time_rounder'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install time_rounder

Usage

TimeRounder has simple methods to access internal classes that calculate the total hours to the nearest quarter hours in a given number of seconds.

TimeRounder.seconds_to_hours(seconds) #seconds is the total seconds to be rounded into quarter hours

TimeRounder can also take a DateTime/Time object and round it to the nearest quarter hour

TimeRounder.rounded_time(date) #date is DateTime/Time object

Development

TimeRounder will continue to be developed adding features and functionality. Some of those features currently planned are:

  • Adding 5, 10, 20 minute rounding schedules.
  • Adding rounding of a date/time object.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rebelweb/time_rounder. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.