Commit 7c3d482f authored by Jérome Perrin's avatar Jérome Perrin

officejs_support_request_ui: simplify date arithmetics

parent 29795b08
from datetime import timedelta
from json import dumps from json import dumps
portal = context.getPortalObject() portal = context.getPortalObject()
# Get the split date # Get the split date
now_date = DateTime() now_date = DateTime().asdatetime()
date_2 = now_date - 2 date_2_midnight = DateTime(now_date - timedelta(days=2)).earliestTime()
date_7 = now_date - 7 date_7_midnight = DateTime(now_date - timedelta(days=7)).earliestTime()
date_30 = now_date - 30 date_30_midnight = DateTime(now_date - timedelta(days=30)).earliestTime()
# we can not use str.join...
date_2_midnight = DateTime(str(date_2.year()) + "-" + str(date_2.month()) + "-" + str(date_2.day()))
date_7_midnight = DateTime(str(date_7.year()) + "-" + str(date_7.month()) + "-" + str(date_7.day()))
date_30_midnight = DateTime(str(date_30.year()) + "-" + str(date_30.month()) + "-" + str(date_30.day()))
support_request_list = portal.portal_catalog( support_request_list = portal.portal_catalog(
portal_type="Support Request", portal_type="Support Request",
select_list=['simulation_state', 'start_date'], select_list=['simulation_state', 'start_date'],
**{"delivery.start_date": {"query": now_date, "range": "ngt"}} **{"delivery.start_date": {"query": DateTime(now_date), "range": "ngt"}}
) )
count_by_state = {} count_by_state = {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment