Skip to content
This repository has been archived by the owner on Apr 14, 2019. It is now read-only.

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

Open
jnmarcus opened this issue Jul 23, 2016 · 4 comments
Open

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

jnmarcus opened this issue Jul 23, 2016 · 4 comments

Comments

@jnmarcus
Copy link

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
Copy link
Collaborator

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

@jnmarcus
Copy link
Author

@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
Copy link
Collaborator

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

@jnmarcus
Copy link
Author

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants