the method `formatEndDate` is really weird and probably won't need to be used multiple times.. I think we should keep it inside this file and use a simpler implementation:

```js
// use the last second of previous day as the base for endDate.
// eg. 1991-09-14T23:59:59 instead of 1991-09-15T00:00:00
endDate = new Date(endDate - 1000);
```