Comment 0 for bug 1361305

Revision history for this message
Thai Tran (tqtran) wrote : Remove hard-coded date formats

We are currently using hard coded date formats in various D3 charts. We should things like "%Y-%m-%dT%H:%M:%S" scattered throughout the code. We should really be using Django's date format. Here are a few of the formats available:

 django.formats = {
    "DATETIME_FORMAT": "N j, Y, P",
    "DATETIME_INPUT_FORMATS": [
      "%Y-%m-%d %H:%M:%S",
      "%Y-%m-%d %H:%M:%S.%f",
      "%Y-%m-%d %H:%M",
      "%Y-%m-%d",
      "%m/%d/%Y %H:%M:%S",
      "%m/%d/%Y %H:%M:%S.%f",
      "%m/%d/%Y %H:%M",
      "%m/%d/%Y",
      "%m/%d/%y %H:%M:%S",
      "%m/%d/%y %H:%M:%S.%f",
      "%m/%d/%y %H:%M",
      "%m/%d/%y"
    ]

As you can see, the hard-coded format is very similar to django.formats.DATE_TIME_INPUT_FORMATS[0]. Why do we wan to do this? Django handles internationalization for us, so it make sense to take advantage of this. It will also centralize the hard-coded date formats into a single place.