namespace-ee / react-calendar-timeline

A modern and responsive react timeline component.
MIT License
1.93k stars 630 forks source link

Simplify API to only expect/return unix timestamp for dates #321

Open mcMickJuice opened 6 years ago

mcMickJuice commented 6 years ago

Thanks for creating an issue! Please fill out the sections below so that we can accommodate your request:

What kind of issue are you experiencing?

This library accepts a moment object, Date or unix timestamp in some cases...but not other cases. Moreover, throughout the app, the code expects dates to be a Moment object...sometimes. I'd like to standardize datetime and require that the values all be unix timestamps.

Pros:

Cons:

gachavez commented 6 years ago

We are moving away from using moment as much as we can because of performance reasons. I would be in favor of unix timestamps.

mcMickJuice commented 6 years ago

Just curious, what kind of performance issues did you face? What actions or situations did moment perform poorly?

jabidof commented 6 years ago

Hi, We're using date-fns that uses the standard Date object. Maybe that is a way.

mcMickJuice commented 6 years ago

I like the approach that this library takes:

/* eslint-disable */
import MuiPickersUtilsProvider from 'material-ui-pickers/utils/MuiPickersUtilsProvider';
// pick a time library utils to inject into the app
import MomentUtils from 'material-ui-pickers/utils/moment-utils';
import DateFnsUtils from 'material-ui-pickers/utils/date-fns-utils';
import LuxonUtils from 'material-ui-pickers/utils/luxon-utils';

function App() {
  return (
    <MuiPickersUtilsProvider utils={DateFnsUtils}>
      <Root />
    </MuiPickersUtilsProvider>
  );
}

render(<App />, document.querySelector('#app'));

The library would expose some standard providers (like the ones in material-ui-pickers). Users could also inject their own, would just need to define the interface.