codefortulsa/oscn

Add a datetime property to Event class

groovecoder opened this issue · 3 comments

When I have an Event object, I'd like to use event.datetime which is a pre-parsed datetime value of the event.Event string.

hmm... I've avoided converting the raw strings and leave that to the end user to decide. Also, could this introduce date format error later down the line?

Most of the other raw string data seems pretty loosely formatted, so it doesn't make sense to try to convert all the raw strings.

But in this case, the event.Event seems to always be a date and time with a consistent formatting. So this will help the calling code from having to duplicate date/time-parsing logic every time.

It could introduce parsing errors, but you should wrap the parsing logic in a try/catch. But handling those date format errors in the libraries means that calling code doesn't have to.

I've added a 'date' key to the event dictionary in version 47. Not ready to take responsibility for conversion to datetime, yet. But this should save you from parsing the date string yourself. Also, the event key is now much cleaner:

{'event': 'PRELIMINARY HEARING ISSUE (PRIVATE ATTORNEY)', 
'party': 'JOBE, MICHAEL LEROY',
'docket': 'Preliminary Hearing Docket',
'reporter': '',
'date': 'Friday, April 6, 2018 at 9:00 AM'}