Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@scoir/date

Package Overview
Dependencies
Maintainers
36
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

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

  • 3.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
167
increased by31.5%
Maintainers
36
Weekly downloads
 
Created
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

Package last updated on 29 Jan 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc