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

distance_of_time_in_words should correct process time periods longer than 1 year defined in seconds #3531

Closed
wants to merge 1 commit into from
Closed

distance_of_time_in_words should correct process time periods longer than 1 year defined in seconds #3531

wants to merge 1 commit into from

Conversation

avakhov
Copy link
Contributor

@avakhov avakhov commented Nov 5, 2011

It differs from #3530 :)

Here I fix side an effect after ae7d0d8 also.

distance_of_time_in_words accepts args as integer (seconds), Date, Time, DateTime or something that responds to :to_time method. If from_time and to_time are seconds for periods more than 1 year date_helper.rb#L97 is interpreted as ActiveSupport year method. In this case creating Range object (fyear..tyear) failes.

I did change nothing in date_helper.rb#L97-110 except indent.

@avakhov
Copy link
Contributor Author

avakhov commented Nov 6, 2011

I updated commit (fixed typo, thanks to Henrik - @dvyjones)

A couple of words about 365.25 days. In that point we need estimate amount of years between two values in seconds. Every 4th year is leap, the real life is more complicated but for this very rare case it's reasonable. The final point why I propose to use 365.25, rails has already this magic constant in Active Support active_support/core_ext/integer/time.rb#L36

@avakhov avakhov closed this Jan 1, 2012
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

Successfully merging this pull request may close these issues.

None yet

1 participant