-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[RFC] Time and Span don't have the same interface for inspection #9002
Comments
I don't understand what's the problem here. The subtraction results seem quite logical to me, this is just basic math. |
You are right. Reading it now I wasn't very clear about what I meant. The issue I'm trying to address is that the inspection methods for Time are in singular (day, hour...) and for Time::Span are in plural (days, hours). Of course I have no issue with the subtraction results and the returned class for each one. |
The singular vs. plural is on purpose: In the usual representation of instances based on time units, each one of them represents a proportional component, such as the second, the minute, the hour, the day, the month, the year of that instance. That's why the methods are in singular form. |
Maybe my non-native english is getting in the middle, but I also consider that you should be dealing with one or the other type usually, but having two similar, yet different APIs for related types is a bit confusing IMO. Time::Span.new(minutes: 60).hours # => 1
Time::Span.new(minutes: 60).minutes # => 0
Time::Span.new(minutes: 60).seconds # => 0
Time::Span.new(minutes: 60).total_minutes # => 60.0
Time::Span.new(minutes: 60).total_seconds # => 3600.0 |
I don't think this is any different in other languages. In spanish for example you ask "¿Qué hora es?" for the time and "¿Cuantas horas?" for a time span. That |
I don't follow why you say they are a different concept @straight-shoota. I understand that a Time::Span is not a Time, but to me both I also fail to see the relationship with #6522. Even if the amount and unit are preserved the |
Okay, so you're just saying that |
I think for a time span you can say: 2, hours, 3 minutes, 5 seconds. Then if you ask "how many minutes" it will say "3". But if you ask "how many total minutes there are" it's a different question. That's at least what the API is modeling, and we copied it from C#. Whether it's good or bad, I don't know. |
No, I don't think @bcardiff is saying that. I think you're just wordplaying to make it fit with the current definitions. You can also say that in Also, |
I'm pretty sure time would still exist even if nobody had invented calendars and clocks to keep track of it 😄 Without going too deep into philosophics, I think that should count as "absolute". However, you're right that it's also legitimiate to describe the time of day as the interval since the beginning of the day. And applied to the smaller units, the minute component as the number of minutes elapsed since the beginning of the hour. |
Yes, I agree we shouldn't reinvent the theory of relativity in this thread 😆 And conventions or not, I agree that |
Since these are not the I don't think it matters much though. |
While starting to use Time and Span for the first time, I encountered with some compiler errors while trying to inspect the result of certain operations. Trying to apply
minute
to a variable sometimes worked, sometimes gave an error.This was due to the different class returned by each of this operations involving Time and Span
I understand that this may come from Mono, but is there a reason why we might wan to keep it like this for 1.0?
This happens with
day
,hour
,minute
andsecond
The text was updated successfully, but these errors were encountered: