workflows: convert date to datetime in anchor expression (#30011)
This commit is contained in:
parent
2f97586642
commit
b9df0e468c
|
@ -3023,6 +3023,15 @@ def test_global_timeouts(pub):
|
|||
assert formdef.data_class().get(formdata1.id).get_criticality_level_object().name == 'yellow'
|
||||
formdata1.store()
|
||||
|
||||
# datetime object
|
||||
trigger.anchor = 'python'
|
||||
trigger.anchor_expression = 'datetime.date(%s, %s, %s)' % (
|
||||
datetime.datetime.now() - datetime.timedelta(days=10)).timetuple()[:3]
|
||||
workflow.store()
|
||||
pub.apply_global_action_timeouts()
|
||||
assert formdef.data_class().get(formdata1.id).get_criticality_level_object().name == 'yellow'
|
||||
formdata1.store()
|
||||
|
||||
# string object
|
||||
trigger.anchor = 'python'
|
||||
trigger.anchor_expression = '"%04d-%02d-%02d"' % (
|
||||
|
|
|
@ -1081,7 +1081,9 @@ class WorkflowGlobalActionTimeoutTrigger(WorkflowGlobalActionTrigger):
|
|||
if isinstance(anchor_date, datetime.datetime):
|
||||
pass
|
||||
elif isinstance(anchor_date, datetime.date):
|
||||
pass
|
||||
anchor_date = datetime.datetime(year=anchor_date.year,
|
||||
month=anchor_date.month,
|
||||
day=anchor_date.day)
|
||||
elif isinstance(anchor_date, time.struct_time):
|
||||
anchor_date = datetime.datetime.fromtimestamp(time.mktime(anchor_date))
|
||||
elif isinstance(anchor_date, basestring) and anchor_date:
|
||||
|
|
Loading…
Reference in New Issue