Project

timefly

0.0
No commit activity in last 3 years
No release in over 3 years
A simple library which makes it easier to get time related data, eg, age from Date of birth, elapsed time in beautiful format, etc.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

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