chronic_duration icon indicating copy to clipboard operation
chronic_duration copied to clipboard

not showing years for large month count

Open ericdp opened this issue 11 years ago • 0 comments

Expecting: 50 years 10 months 11 days (18,578 days)

Actual: 619 mos 8 days (18,578 days)

The calculation for years seems to be off.

irb> require 'date'
=> true
irb> require 'chronic_duration'
=> true

irb> b = Date.new( 1963, 11, 27 )
=> #<Date: 1963-11-27 ((2438361j,0s,0n),+0s,2299161j)>

irb> puts "birthdate : #{b.strftime('%a, %d %b %Y')}"
birthdate : Wed, 27 Nov 1963
=> nil

irb> bj = b.jd
=> 2438361

irb> n = Date.today
=> #<Date: 2014-10-08 ((2456939j,0s,0n),+0s,2299161j)>

irb> puts "now       : #{n.strftime('%a, %d %b %Y')}"
now       : Wed, 08 Oct 2014
=> nil

irb> nj = n.jd
=> 2456939

irb> d = n - b
=> (18578/1)

irb> dj = nj - bj
=> 18578

irb> puts "age       : " << ChronicDuration.output( ( ( dj * 24 * 60 * 60 )) ) << " (#{dj} days)"
age       : 619 mos 8 days (18,578 days)
=> nil

ericdp avatar Oct 08 '14 15:10 ericdp