Open thet opened 4 years ago
Yes, I have already found this issue, you can replace None with datetime.min or datetime.max according to your needs:
>>> from datetime import datetime
>>> sorted((datetime.today(), None), key=lambda x: x or datetime.min)
[None, datetime.datetime(2020, 5, 15, 12, 49, 22, 317443)]
Ah! And also the indexer should be something like:
def start(obj):
return obj.start or datetime.min
I encountered an issue with special events with optional start and end dates.
For that I created a behavior which derives from plone.app.event.dx.behaviors.IEventBasic, which itself implements plone.app.event.dx.interfaces.IDXEvent, which itself derives from plone.event.interfaces.IEvent which is used as search criteria in plone.app.event.base.get_events.
When using
get_events
and sorting onstart
like so:it breaks with:
I see the following options:
sorted(iterable, *, key=None, reverse=False)
to transform missing values into a ceiling dateAny opinions? /cc @jensens @ale-rt @mauritsvanrees