Open giuliolunati opened 3 years ago
Subtracting dates has historically defaulted to the date-value/date
only for reasons—I suspect, at least—of the more common operation: calculating the number of days between two dates. You can get your 1:00
by using difference
. I don't know if that's the right way to ultimately do it, but that calculation is available:
>> difference now now - 1
== 24:00
Subtracting two date values should also give a resulting date value but it produces an integer!
On Fri, 1 Oct 2021, 11:37 Christopher Ross-Gill, @.***> wrote:
Subtracting dates has historically defaulted to the date-value/date only for reasons—I suspect, at least—of the more common operation: calculating the number of days between two dates. You can get your 1:00 by using difference. I don't know if that's the right way to ultimately do it, but that calculation is available:
difference now now - 1
== 24:00
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/metaeducation/ren-c/issues/1135#issuecomment-931751278, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABR4QQOE34F343MUA5QXUTUETRCRANCNFSM5FDGVDCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
@gchiu: Subtracting two date values should also give a resulting date value
That doesn't make any sense. You don't subtract February from March and get January.
It's reasonable to imagine date math giving back a TIME!. Then have days months years accessors for time to help you decode the result.
>> t: 8:00 + 23:00
== 31:00
>> t.days
== 1
The tricky part is that you wind up with questions of t.hours being 7 or 31. And you have negative values... which components of a negative time are negative? All of them?
It's a messy domain. As @rgchris says, DIFFERENCE is the historical answer, and it's not a great one.
February and March aren't dates
---Original--- From: "Hostile @.> Date: Fri, Oct 1, 2021 17:08 PM To: @.>; Cc: "Graham @.**@.>; Subject: Re: [metaeducation/ren-c] DATE difference should be a TIME (#1135)
@gchiu: Subtracting two date values should also give a resulting date value
That doesn't make any sense. You don't subtract February from March and get January.
It's reasonable to imagine date math giving back a TIME!. Then have days months years accessors for time to help you decode the result.
>> t: 8:00 + 23:00 == 31:00 >> t.days == 1
The tricky part is that you wind up with questions of t.hours being 7 or 31. And you have negative values... which components of a negative time are negative? All of them?
It's a messy domain. As @rgchris says, DIFFERENCE is the historical answer, and it's not a great one.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
February and March aren't dates
They are DATE! components, and once they're part of the math then you can't subtract them and get another one of them.
Still less than satisfactory: date! despite the time component is intuitively, if imperfectly, a measure of days, thus I think it still appropriate that one date less another yield an integer! (unless you want to get into the uncomfortable realm of returning decimal! for e.g. now - (now - 6:00) => 0.25) which with zones could get messier still). Dates could have a, say, epoch or fixed (or something) accessor that returned the time! elapsed since an arbitrary date (sigh, let's run with Jan 1st, 1970 as a for instance) that you may get the difference in hours by stating: date1/elapsed - date2/elapsed.
Or perhaps that assumption is wrong and returning the hourly difference between two dates is correct. Then getting the count of days between two dates is a further round date1 - date2 / 24:00
d0: 1-1-2021/0:00+0:00
d1: d0 + 1:00, d1 = 1-1-2021/1:00+0:00
Butd1 - d0 = 0
I would expected1:00