@scoir/date

3.0.0 • Public • Published

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: '&mdash;',
                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)
        ...
    }
    ...
}

Readme

Keywords

none

Package Sidebar

Install

npm i @scoir/date

Weekly Downloads

80

Version

3.0.0

License

UNLICENSED

Unpacked Size

16.1 kB

Total Files

19

Last publish

Collaborators

  • jasonblanchard
  • alittletonscoir
  • rocky.egawa
  • eric.kertzscoir
  • bonsebas
  • brynkng
  • azragal
  • jhudzik
  • jaymi_johnson
  • jspencer_scoir
  • dkozicki
  • scoir-kevinrathgeber
  • sully-scoir
  • smclaughlin-scoir
  • sbeyers
  • eriksuman
  • robelder
  • scoir-alexr
  • danancook
  • dmscoir
  • cbartlett33
  • jpshrader
  • cmccrory
  • ahagner
  • rrosenthal
  • cellisscoir
  • dbyler_scoir
  • mvannucciscoir
  • kjbillings
  • ccarson_scoir
  • scoir-dev
  • daynek
  • pjohnson11120
  • gakhvledi
  • thos-scoir
  • scoir-devops