Open nick-chandoke opened 4 years ago
Yeah, I obviously had some muddled thinking here. This is a real design flaw.
Unfortunately, a (regrettabl) part of gregor
's design is that you're allowed to ask for the period between two objects of different concrete types. So, for example, you can ask for the number of seconds between, say, a datetime
and a moment
, which is really not a good idea.
That's the real reason between
functions don't work on time
s. An arbitrary choice of date would fail when confronted by a case using a real date. You'd probably then want to use the date of the object you're being compared to, and I bet I considered that at some point.
These days I'm convinced that between
functions should require the right and left hand sides to be the same type of temporal object.
But, as for now, you're right that time-period-between
doesn't live up to its contract. Hmm...
The example expression
(time-period-between (time 10 30) (time 11 00) '(seconds))
fails becauseseconds-between
(and any other *-between functions) requiredatetime-provider?
, as per their contracts. Thustime-period-between
fails for alltime-provider?
that aren'tdatetime-provider?
, regardless of fields. An easy fix is providing datetimes with dummy year, month, and date, e.g.(time-period-between (datetime 1 1 1 10 30) (datetime 1 1 1 11 00) '(seconds))
, but at this pointtime-period-between
is identical toperiod-between
.