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

Add methods [days, weeks, months, years]_between #27966

Closed

Conversation

bogdanvlviv
Copy link
Contributor

@bogdanvlviv bogdanvlviv commented Feb 10, 2017

I think it might be useful, so i decided to make this PR.

Added methods:
#days_between
returns the number of days to given date, default to +Date.current+.

#weeks_between
returns the number of weeks to given date, default to +Date.current+.

#months_between
returns the number of months to given date, default to +Date.current+.

#years_between
returns the number of years to given date, default to +Date.current+.

Your thoughts guys?

  `#days_between`
  returns the number of days to given date, default to +Date.current+.

  `#weeks_between`
  returns the number of weeks to given date, default to +Date.current+.

  `#months_between`
  returns the number of months to given date, default to +Date.current+.

  `#years_between`
  returns the number of years to given date, default to +Date.current+.
@rails-bot
Copy link

r? @rafaelfranca

(@rails-bot has picked a reviewer for you, use r? to override)

@rafaelfranca
Copy link
Member

Thank you so much for the pull request but we avoid adding new methods to active record core extension unless it is useful for the framework or many web applications.

@bogdanvlviv
Copy link
Contributor Author

how to know does it useful for many web application?
I see a lot of info on queries in Google:
"rails days beetwen dates"
"rails month beetwen dates"
"rails years between dates'

@chrisarcand
Copy link
Contributor

chrisarcand commented Feb 10, 2017

I agree with @rafaelfranca. Please keep in mind that if it's really common enough for your frequent use, it still needn't be a part of ActiveSupport but seems like a great idea for a simple gem. (I just found https://github.com/abhidsm/time_diff as such an example)

@bogdanvlviv
Copy link
Contributor Author

@chrisarcand i agree, thanks for explanation!

bogdanvlviv added a commit to bogdanvlviv/general_time that referenced this pull request Feb 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants