[ruby-core:87663] [Ruby trunk Feature#14877] Calculate age in Date class

From: shevegen@...
Date: 2018-06-28 11:40:17 UTC
List: ruby-core #87663
Issue #14877 has been updated by shevegen (Robert A. Heiler).


I am not sure if .age() is a "proper name" or not, so I can't really decide
on that. But I specifically wanted to add two things:

a) not all names necessarily fit towards the ruby object model as-is. Ultimately
you have to ask matz about what fits and what does not fit, but several methods
in the active* ecosystem (the gems) do not make a lot of sense from a "pure"
OOP point of view, in my opinion. That is not to say that these methods never
make sense, mind you (when I suggested ... I think it was .append() or something,
I was not even aware of the active* ecosystem; I only noticed that from a twitter
message how ruby core adds active* stuff ... but I don't use rails etc.. so I
came from a completely different point of view, yet the suggestion seems to 
have made sense to matz back then.)

So TL;DR, I think one has to decide on a case-by-case basis whether it fits or
not, API-wise that is.

b) as for your other comment, in regards to StackOverflow, but even more importantly,
what people use with ruby, I actually agree. I think if people keep on having the
same issue over and over again, it may be where the core of ruby could be improved.

Date/Time related stuff is something that I feel is coming up every now and then,
so in this general area I agree - also because I think it is something lots of
people use ruby with.

By the way, it may also help to add a description what the method .age() does,
because with a missing description, others have to fill in so it adds to their
burden of implementation. It's much easier for the core team to add methods
when there is a clear documentation associated with it - but it is your suggestion,
not mine, feel free to proceed in any way that you see fit.

I personally use the "poor man's approach", always calculating in seconds. :P

----------------------------------------
Feature #14877: Calculate age in Date class
https://bugs.ruby-lang.org/issues/14877#change-72685

* Author: derosm2 (Mike DeRosa)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Seems like there's enough complexity in determining the right values and it's something a ton of apps have to address. I've seen a bunch of StackOverflow and other blog posts attempt to address this, not all of them accurately.

`Date.new(2016, 3, 6).age #=> 2`



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next