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
778 stars 254 forks source link

Date and time format problem #792

Closed Electricity2015 closed 3 weeks ago

Electricity2015 commented 3 months ago

image

The date and time are not formated like in metadata

the result is :

image

jhpyle commented 3 months ago

The metadata settings are date format and time format, not format date and format time. https://docassemble.org/docs/initial.html#date%20format

A datatype: time field defines a datetime.time object. https://docassemble.org/docs/fields.html#time

Thus when the object is reduced to text, the textual representation depends on the datetime package, which doesn't know anything about docassemble or docassemble's metadata settings.

The metadata setting time format is used when format_time() is called without a format parameter.

metadata:
  date format: dd.MM.YYYY
  time format: HH.mm
---
question: |
  Date and time
fields:
  - Date: example_date
    datatype: date
  - Time: example_time
    datatype: time
---
mandatory: True
question: |
  Text representation
subquestion: |
  Date: ${ example_date }

  Time: ${ format_time(example_time) }
jhpyle commented 3 weeks ago

Closing due to lack of activity.