espenmn
(Espen)
July 13, 2018, 5:21pm
1
I am making a 'batch by day' view.
How do I search for just one day ?
If i use the code below I get 'two days' and if I change offset_e to 3 I get 'nothing'
oftset_s = 3
offset_e = 4
today = datetime.date.today()
start_date = today + datetime.timedelta(days=offset_s)
end_date = today + datetime.timedelta(days=offset_e)
date_range = {
'query': (
start_date,
end_date,
),
'range': 'min:max',
}
return self.context.portal_catalog(Type='Movie', start=date_range, sort_on='start')
jaroel
(Roel Bruggink)
July 13, 2018, 8:24pm
2
thet
(Johannes Raggam)
July 13, 2018, 8:57pm
3
just a quick note:
start_date < day after
end_date > today, beginning of the day
Also see:
:returns: datetime set to the end time of the day (23:59:59).
:rtype: Python datetime
"""
if not isinstance(dt, datetime):
# is a date
dt = datetime.fromordinal(dt.toordinal())
return dt.replace(hour=23, minute=59, second=59, microsecond=0)
def start_end_from_mode(mode, dt=None, context=None):
"""Return a start and end date from a given mode string, like
"today", "past" or "future". This can be used in event retrieval
functions.
:param mode: One of the following modes:
'all' Show all events.
'past': Show only past events with descending sorting.
'future': Show only future events (default).
'today': Show todays events.
not sure, if that helps.
jaroel
(Roel Bruggink)
July 16, 2018, 11:11am
5
Did you fix you problem, if so what did you end up doing?
espenmn
(Espen)
July 16, 2018, 1:09pm
6
Yes I got it fixed, but your links also got me to looks at the events 'way of doing it' ( which makes it possible to set the dates in the url).
So now I am subclassing the Events view if I only could get 'scale' to work (I can probably get around this by constructing the image url) and adding two more fields ( hashtag and category)