jhpyle / docassemble

A free, open-source expert system for guided interviews and document assembly, based on Python, YAML, and Markdown.
https://docassemble.org
MIT License
768 stars 252 forks source link

Interview datatype date is returning 'Bad date' in the downloded document #756

Closed guidupas closed 1 month ago

guidupas commented 5 months ago

I have created an interview with a field defined as date datatype. When I download my document it has a 'Bad date' where the date should be.

Screenshot from 2024-03-19 14-11-07 Screenshot from 2024-03-19 14-11-37

jhpyle commented 5 months ago

I attempted to reproduce this issue with the following interview. I did not get a "Bad date" problem.

mandatory: True
question: Your document
attachment:
  docx template file: testdate.docx
---
question: |
  Date
fields:
  - Date: some_date
    datatype: date

Here is the document: testdate.docx

I will need more information such as your interview YAML and the document you are trying to assemble.

guidupas commented 5 months ago

Yes. It worked with your document. But I can´t se anything wrong with my template. What could return this 'Bad date' error?

jhpyle commented 5 months ago

The date formatting functions fall back to inserting "Bad date" if there is an error, such as if a date formatting function is called on a variable that is not a date object, or the variable is a string that cannot be parsed as a date, or if the babel.dates.format_datetime() function cannot handle the given language. If the language is pt, that is one of the languages that babel.dates.format_datetime() supports, so it ought to work. See also https://docassemble.org/docs/config.html#babel%20dates%20map

guidupas commented 5 months ago

Thank you very much. I will take a better look here

jhpyle commented 1 month ago

Closing this due to inactivity.