Skip to content

ponnusamygit/time_subtract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TimeSubtract Code Climate Dependency StatusGem Version

Get the difference between two time

Installation

Add this line to your application's Gemfile:

gem 'time_subtract'

And then execute:

$ bundle

Or install it yourself as:

$ gem install time_subtract

Usage

time.smart_subtract time2

date.smart_subtract date2

# This will return 

	'2 years 1 month 8 days 10 hours 5 minutes 23 seconds'.

If you want result as hash

time.smart_subtract(time2, hash: true)

# or

date.smart_subtract(date2, hash: true)

# or

(time - time2).time_diff_hash

# or

seconds = 123456

seconds.time_diff_hash

# This will return

#=> {:year => 0, :month => 0, :day => 1, :hour=> 10, :minute => 17, :second => 36}

Contributing

  1. Fork it ( https://github.com/ponnusamygit/time_subtract/fork )
  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 a new Pull Request

Maintainer

Todo

  • Get format from user

Testing

Time Subtract uses RSpec for test coverage. Inside the gem directory, you can run the specs with:

rpsec spec/time_subtract_spec.rb

License

MIT

About

Get difference between two time

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages