You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to compare periods for sorting etc.
Clearly this is tricky when months and years are involved, and clearly there's
no way to create an IAlmostComparableSortOf interface, but it seems likely that
there is a "common-sense" (or useful) answer to most of the problems:
4 weeks is less than 1 month (nearly always)
4 weeks is never more than 1 month (always)
12 months is equal to 1 year (in most cases)
52 weeks is less than a whole year (always)
etc.
And even when there isn't, it's still useful to present an 'almost certainly
sorted' list to a user instead of not being able to show anything.
Original issue reported on code.google.com by HighTech...@gmail.com on 19 Apr 2012 at 3:42
The text was updated successfully, but these errors were encountered:
I don't want to provide something which is "sorta right". If you want to do so,
you can certainly implement IComparer<Period> yourself. If enough people ask
for this, we can try to nail down *exactly* what rules would satisfy demand,
but I'm very reluctant to put it in now.
Original comment by jonathan.skeet on 19 Apr 2012 at 6:09
Scratch that - I've thought of a way of making it a decent comparer that I
won't be unhappy with.
I'm not actually going to make Period implement IComparable<Period>, but I'll
provide a method to create an IComparer<Period> *with a given "base"
LocalDateTime*. The result of comparing two periods will be the result of
(baseDateTime + period1).CompareTo(baseDateTime + period2).
Original comment by jonathan.skeet on 19 Apr 2012 at 7:29
Original issue reported on code.google.com by
HighTech...@gmail.com
on 19 Apr 2012 at 3:42The text was updated successfully, but these errors were encountered: