Socket
Socket
Sign inDemoInstall

@scoir/date

Package Overview
Dependencies
6
Maintainers
36
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @scoir/date

The date utility provides a useRelativeTime, formatter (deprecated), and isCredibleDate (deprecated) utility


Version published
Weekly downloads
419
increased by93.98%
Maintainers
36
Created
Weekly downloads
 

Readme

Source

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)
        ...
    }
    ...
}

FAQs

Last updated on 29 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc