Date
The date utility provides a formatter and isCredibleDate utility
Usage - formatter
Use the format method with your date and an option configuration object.
The configuration can take defaultText, inputFormat, and an outputFormat.
import { formatter } from '@scoir/date';
class ExampleComp extends React.Component {
static propTypes = { someDate: PropTypes.string }
render () {
const formattedDate = formatter.format(this.props.someDate, {
defaultText: '—',
inputFormat: 'MM-DD-YYYY',
outputFormat: 'ddd, hA',
})
...
}
...
}
Usage - isCredibleDate
A method returning a boolean for a non-falsy and non-zero-date date input
import { isCredibleDate } from '@scoir/date';
class ExampleComp extends React.Component {
static propTypes = { someDate: PropTypes.string }
render () {
const isNotTrashGarbage = isCredibleDate(this.props.someDate)
...
}
...
}