Skip to content

max-power/age

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Age

Installation

Add this line to your application's Gemfile:

gem 'power-age'

And then execute:

$ bundle

Or install it yourself as:

$ gem install power-age

Usage

Age::now(timestamp)

shortcut for Age.new(timestamp).now

Age::new(timestamp)

Age#new accepts a Time, Date or DateTime object as argument.

Age#now

birthday = Time.new(1990, 3, 14)
Age.new(birthday).now

Age#at(timestamp)

User  = Struct.new(:dob)
Event = Struct.new(:start_date)
event = Event.new(Time.new(2020, 2, 20))
user  = User.new(Time.new(1970, 6, 21))

Age.new(user.dob).at event.start_date