module Years
Provides some year-related methods.
Constants
- VERSION
Public Class Methods
tells the age of someone, with truncation, where the leapling legal birthday is 1 March @param (see Years.age_where_leapling_legal_birthday_is_28_feb
) @param (see Years.age_where_leapling_legal_birthday_is_28_feb
) @return (see Years.age_where_leapling_legal_birthday_is_28_feb
)
# File lib/years.rb, line 19 def self.age_where_leapling_legal_birthday_is_1_mar date_of_birth, today=Date.current age date_of_birth, today, :mar1 end
tells the age of someone, with truncation, where the leapling legal birthday is 28 February @param [Date] date_of_birth the person's date of birth @param [Date] today the day that you want to know their date of birth for, defaults to today @return [Fixnum]
# File lib/years.rb, line 11 def self.age_where_leapling_legal_birthday_is_28_feb date_of_birth, today=Date.current age date_of_birth, today, :feb28 end
tells the age of someone, with truncation, where the leapling legal birthday is 28 February @param [Fixnum] first_year the first year of the range, say the year of company creation @param [Fixnum] last_year the last year of the range, defaults to this year @return [String]
# File lib/years.rb, line 27 def self.range first_year, last_year=Date.current.year raise if first_year > last_year (first_year == last_year) ? first_year.to_s : first_year.to_s + @@EN_DASH + last_year.to_s end
Private Class Methods
# File lib/years.rb, line 35 def self.age date_of_birth, today, legal_leapling_birthday raise if today < date_of_birth years = today.year - date_of_birth.year (birthday(date_of_birth, years, legal_leapling_birthday) > today) ? years - 1 : years end
# File lib/years.rb, line 42 def self.birthday date_of_birth, years, legal_leapling_birthday bday = date_of_birth.years_since years (leapling?(date_of_birth) and legal_leapling_birthday == :mar1) ? bday.tomorrow : bday end
# File lib/years.rb, line 51 def self.february_29th? date date.mday == 29 and date.mon == 2 end
# File lib/years.rb, line 47 def self.leapling? date february_29th? date end