Open rlskoeser opened 1 year ago
S&co approach was to store date as a DateField
to take advantage of django and postgres date sorting and filtering, and store a precision object in parallel, that tracked which portions of the date were known. A descriptor was used to combine the date and precision flag into a PartialDate
that took the known/unknown portions into account. We have a custom queryset filter for filtering on whether a year is known or not based on that precision flag. We created a model mixin that included start and end date (adds precision flag and partial date descriptors).
Date precision flag was never set directly, but was set based on parsing and validating the supported date formats entered into the system, and then used for serializing back out into the needed format. Preferred access was through the descriptor field that combined the date and the precision; some operations required knowing how this was set up (e.g. queryset to filter on start date but then filter to dates with known years)
Here's the python-edtf
approach to an EDTFField
: https://github.com/ixc/python-edtf/blob/master/edtf/fields.py
resources: