caciviclab / disclosure-backend

DEPRECATED (We're working on the `disclosure-backend-static` repo instead) A Django app to download, extract and load campaign finance and lobbying activity data from the California Secretary of State's CAL-ACCESS database as well as local Netfile jurisdictions
https://github.com/caciviclab/disclosure-backend-static/
11 stars 20 forks source link

Convert dates to standard ISO 8601 date/time string #254

Open jnmarcus opened 8 years ago

jnmarcus commented 8 years ago

is it possible to convert dates to this format for the front-end to consume? Otherwise we'll have to do a whole bunch of string manipulations for every date. Just to format the strings as a date. So that we can do something else with them afterwards...

bcipolli commented 8 years ago

What about using https://www.npmjs.com/package/dateformat ?

jnmarcus commented 8 years ago

@bcipolli it's not that we can't do it on the front-end. Angular already has built in filters that allow us to change how the date looks, but it only accepts ISO 8601, because this is the most standardized. We could use the native JavaScript date object, but that's not always consistent, (depending on the browser). I could also strip out the slashes, format the date with Angular and then put the slashes back in, but that just adds to the amount of code that will need to be applied to every single date that we display on a page, unnecessarily, which affects load time, user experience, etc...

Also, I've noticed that the format for dates that are being returned in the API, varies. For example, the date for report_date returned when a committee id is called at http://admin.caciviclab.org:80/committee/{committee_id}/contributions is in ISO 8601 format (YYYY-MM-DD), while the date returned when a ballot id is called at http://admin.caciviclab.org:80/ballot/{ballot_id} is in the format YYYY/MM/DD (locale).

Basically, this isn't super urgent, but it'd be nice to standardize on this in general. If the data coming back from Netfile is in multiple formats, we may want to bring this to their attention. If it isn't, and we're formatting the dates with slashes (aka locale), we shouldn't. Date and time can get confusing, and if locale format is used, it can sometimes result in what (in our case) could be perceived as multiple instances in time, for the same moment in time (you can read more about it here)

bcipolli commented 8 years ago

Gotcha, sounds good :+1:. Definitely the dates should be standardized when they are stored, and output in a standardized format :)

jnmarcus commented 8 years ago

👍