Hello,
I tried to make a perspective script to add days but exclude weekdays. Everything fine on Script Console but when I test it on Perspective, I have the next error.
Error running property change script on DateTimeInput.props.value: Traceback (most recent call last): File “function:valueChanged”, line 39, in valueChanged File “function:valueChanged”, line 32, in date_by_adding_business_days AttributeError: type object ‘datetime’ has no attribute ‘timedelta’
My Script:
from datetime import timedelta
from datetime import datetime
z = '20220303' #date
def date_by_adding_business_days(from_date, add_days):
business_days_to_add = add_days
current_date = from_date
while business_days_to_add > 0:
current_date += datetime.timedelta(days=1)
weekday = current_date.weekday()
if weekday >= 5: # sunday = 6
continue
business_days_to_add -= 1
return current_date
self.view.getChild("root").custom.test5 = date_by_adding_business_days(z, 20)
Script console