No commit activity in last 3 years
No release in over 3 years
Extra methods for Date, Time, and DateTime
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.1.1
~> 1.0.0
~> 0.9.1
~> 2.10.0
~> 0.6.4
~> 0.3.5

Runtime

< 4, >= 3.0.0
>= 0
 Project Readme

TimeCalculations

Extra methods for Date, Time, and DateTime.

Installation

Add this line to your application's Gemfile:

gem 'time_calculations'

And then execute:

$ bundle

Or install it yourself as:

$ gem install time_calculations

Usage

Time.parse('2002-02-02 02:02:02').beginning_of_hour   == Time.parse('2002-02-02 02:00:00')
Time.parse('2002-02-02 02:02:02').beginning_of_minute == Time.parse('2002-02-02 02:02:00')

Time.parse('2002-02-02 02:02:02').round_up(:year)   == Time.parse('2003-01-01 00:00:00')
Time.parse('2002-01-01 00:00:00').round_up(:year)   == Time.parse('2002-01-01 00:00:00')
Time.parse('2002-02-02 02:02:02').round_up(:month)  == Time.parse('2002-03-01 00:00:00')
Time.parse('2002-02-01 00:00:00').round_up(:month)  == Time.parse('2002-02-01 00:00:00')
Time.parse('2002-02-02 02:02:02').round_up(:day)    == Time.parse('2002-02-03 00:00:00')
Time.parse('2002-02-02 00:00:00').round_up(:day)    == Time.parse('2002-02-02 00:00:00')
Time.parse('2002-02-02 02:02:02').round_up(:hour)   == Time.parse('2002-02-02 03:00:00')
Time.parse('2002-02-02 02:00:00').round_up(:hour)   == Time.parse('2002-02-02 02:00:00')
Time.parse('2002-02-02 02:02:02').round_up(:minute) == Time.parse('2002-02-02 02:03:00')
Time.parse('2002-02-02 02:02:00').round_up(:minute) == Time.parse('2002-02-02 02:02:00')

Contributing

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