Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not showing years for large month count #34

Open
ericdp opened this issue Oct 8, 2014 · 0 comments
Open

not showing years for large month count #34

ericdp opened this issue Oct 8, 2014 · 0 comments

Comments

@ericdp
Copy link

ericdp commented Oct 8, 2014

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant