You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Date math with format_date is a little confusing with the requirement to convert the Docassemble built-in date type and the function name "format_date" doesn't make it clear you can use it for date math. EDIT: I see now that the format_date part is not needed.
Get a date in the interview variable case.answer_date, and add 2 weeks to it:
With example 1, you need to change the format of the date in the interview into a datetime. Otherwise you get an error that is confusing for a novice like me:
Error
TypeError: coercing to Unicode: need string or buffer, relativedelta found
I tested it with format_date(today() + date_interval(days=14)) which worked, so today() appears to a return a datetime while Docassemble datatype: date does not.
I suggest adding wrapper functions for add_days, add_months, etc, or alternatively, add_dateinterval that accepts the same arguments as date interval. It should work without requiring the interview author to convert a Docassemble date to a datetime. I think for legal applications, add_days would be most common though? Perhaps also add_years?
E.g.: add_days(case.answer_date, 14) or add_dateinterval(case.answer_date, days=14). It should accept both the Docassemble date datatype and the datatype of the today() function.
The text was updated successfully, but these errors were encountered:
Alternatively--if it's not a breaking change, datatype: date could default to a datetime object instead of the current format, so it works with the existing examples?
Date math with format_date is a little confusing with the requirement to convert the Docassemble built-in date type and the function name "format_date" doesn't make it clear you can use it for date math. EDIT: I see now that the format_date part is not needed.
With example 1, you need to change the format of the date in the interview into a datetime. Otherwise you get an error that is confusing for a novice like me:
I tested it with format_date(today() + date_interval(days=14)) which worked, so today() appears to a return a datetime while Docassemble datatype: date does not.
I suggest adding wrapper functions for add_days, add_months, etc, or alternatively, add_dateinterval that accepts the same arguments as date interval. It should work without requiring the interview author to convert a Docassemble date to a datetime. I think for legal applications, add_days would be most common though? Perhaps also add_years?
E.g.: add_days(case.answer_date, 14) or add_dateinterval(case.answer_date, days=14). It should accept both the Docassemble date datatype and the datatype of the today() function.
The text was updated successfully, but these errors were encountered: