3.0.0 • Published 1 year ago
@scoir/date v3.0.0
Date
The date utility provides a useRelativeTime, formatter (deprecated), and isCredibleDate (deprecated) utility
Usage - useRelativeTime
Use the useRelativeTime method with your date string to recieve a formatted string relative to now that updates every 60 seconds.
import { useRelativeTime } from '@scoir/date';
const ExampleComp = () => {
const formattedDate = useRelativeTime('2024-01-05T19:17:39.875Z')
render (
<Typography>{formattedDate}</Typography>
...
)
...
}
Usage - formatter - deprecated
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 - deprecated
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)
...
}
...
}
3.0.0
1 year ago
2.0.4-2
1 year ago
2.0.4-1
1 year ago
2.0.4-0
1 year ago
2.0.3
1 year ago
2.0.2
2 years ago
2.0.1
3 years ago
2.0.0-beta.b0e6db42
3 years ago
2.0.0-beta.ed162590
3 years ago
2.0.0
3 years ago
1.1.4
7 years ago
1.1.3
7 years ago
1.1.1
7 years ago
1.1.0
7 years ago
1.0.1-1.1
7 years ago
1.0.1-1.0
7 years ago
1.0.0
7 years ago