dh-tech / undate-python

A Python library for working with fuzzy, partial, or otherwise uncertain dates
Apache License 2.0
8 stars 1 forks source link

create custom django fields for working with undate and undate interval in a django database #68

Open rlskoeser opened 1 year ago

rlskoeser commented 1 year ago

resources:

rlskoeser commented 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)

ColeDCrawford commented 6 months ago

Here's the python-edtf approach to an EDTFField: https://github.com/ixc/python-edtf/blob/master/edtf/fields.py