dfurtado / dataclass-csv

Map CSV to Data Classes
Other
194 stars 21 forks source link

datetime: support a formatter function in addition to the existing dateformat string #17

Open rtdean opened 5 years ago

rtdean commented 5 years ago

While the existing datetime support is nice, some additional flexibility would be nice. When reading date strings, for example, the ability to use a well known parser such as dateutil.parser or, the ability to manipulate the datetime object as it's created (such as making sure the conversion to UTC happens correctly, if needed), or even to instantiate a datetime from a non-human format, such as a unix timestamp.

To that end, in addition to the dateformat metadata that exists today, maybe some sort of datefactory or dateformatter metadata, which would be a callable, passing in the value, and returning a well-formed datetime object would be useful.

dfurtado commented 5 years ago

Hello @rtdean !!

Sorry for the late reply. Yeah, I agree it would be very parsing dates the right way. Is that something that you would be interested in implementing?