0.0
No commit activity in last 3 years
No release in over 3 years
Make it easy to handle numeric value as seconds.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.8
~> 12.0
~> 0.79
 Project Readme

TimeSecond

Gem Version Build Status Maintainability Test Coverage

Make it easy to handle numeric value as seconds.

Installation

Add this line to your application's Gemfile:

gem 'time_second'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install time_second

Usage

# New from Integer
t = TimeSecond.new(2 * 60 * 60 + 1 * 60 + 39) # 2:01:39
t.hour   #=> 2
t.minute #=> 1
t.second #=> 39
t.hms    #=> '02:01:39'
t.hm     #=> '02:01'

# New from String
t = TimeSecond.parse('02:01:39')
t.to_i #=> 7299

# Support basic arithmetic operations
t = TimeSecond.new(7)
t + 3   #=> 10
t - 3   #=> 4
t * 3   #=> 21
t / 3   #=> 2
t / 3.0 #=> 2.3333333333333335
t % 3   #=> 1

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/toreta/time_second.

License

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