Home

Awesome

TimeSugar Build Status Code Climate Code Climate Coverage Dependency Status Gem Version

Syntactic sugar for handling time. If you are familiar with Active Support, but you don't want to add the whole library for just handling time, time_sugar may be helpful.

Installation

Add this line to your application's Gemfile:

gem 'time_sugar'

And then execute:

$ bundle

Or install it yourself as:

$ gem install time_sugar

Usage

Time sugar add some utility methods to Fixnum, which are useful for doing stuff like this:

1.second #=> 1
1.minute #=> 60
1.hour #=> 3600
1.day #=> 86400
1.week #=> 604800

Time.now #=> 2014-02-11 23:55:47 -0300
1.minute.ago #=> 2014-02-11 23:55:46 -0300

Time.now #=> 2014-02-11 23:55:47 -0300
1.minute.ago #=> 2014-02-11 23:54:47 -0300

Time.now #=> 2014-02-11 23:55:47 -0300
1.hour.ago #=> 2014-02-11 22:55:47 -0300

Time.now #=> 2014-02-11 23:55:47 -0300
1.day.ago #=> 2014-02-10 23:55:47 -0300

Time.now #=> 2014-02-11 23:55:47 -0300
1.week.ago #=> 2014-02-04 23:55:47 -0300

Is it any good?

I don't know!

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

See the LICENSE.