Skip to content

#in_months doesn't seem to respect months having different days #39

@pedantic-git

Description

@pedantic-git

I'm trying to use TimeDifference to find the difference in months between two dates. I'd expect the difference between 2017-09-04 and 2017-12-04 to be exactly 3.0.

But this happens:

TimeDifference.between(Time.new(2017, 9, 4), Time.new(2017, 12, 4)).in_months
#=> 2.99
TimeDifference.between(Time.new(2017, 8, 4), Time.new(2017, 11, 4)).in_months
#=> 3.02

Would it make sense to add an #in_calendar_months or similar that takes into account the different lengths of different months?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions