Skip to content

gsingharoy/timefly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Timefly

Gem Version Build Status

A simple library which makes it easier to get time related data, eg, age from Date of birth, elapsed time in beautiful format, etc.

Installation

gem install timefly

Usage

To initialize you can pass an instance of Time, Date or a String

require 'timefly'

Timefly.new(Time.new(1987, 8, 2))
#str_origin_time can be String or formats YYYY.MM.DD, YYYY-MM-DD, YYYY/MM/DD
Timefly.new(str_origin_time)

To get the elapsed time

Timefly.new(origin_time).elapsed_time
# => 4 hours ago

To get a custom format of the elapsed_time

Timefly.new(origin_time).elapsed_time(format: '%n%u')
# => 4h
# %n - numeric value of the difference
# %u - short form of the unit
# %U - full unit

To get the age from date of birth

# dob is the date of birth
Timefly.new(dob).age
# => 27

If you want to retrieve age in years and months then

Timefly.new(dob).age({ format: '%y years, %m months' })
# => 27 years, 10 months

Contributing

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages