New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@helga-agency/relative-time

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helga-agency/relative-time

Custom element that displays localized relative time (e.g. '4 days ago')

  • 1.3.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Relative Time

Displays relative time (e.g. '3 days ago') in a custom element. Uses best guesses to decide what unit (e.g. day, week etc.) to use.

Advantages

  • Good test coverage
  • Custom element (no vendor dependencies)
  • Small file size
  • Uses standard JS functionality (Intl.RelativeTimeFormat) with broad browser support
  • Use within a HTML <time> element to get optimum semantics

Example

<!-- Use browser's locale -->
<relative-time data-time="2023-03-02 10:00:03">2023-03-02</relative-time>

<!-- Use de as locale -->
<relative-time data-time="2023-03-02 10:00:03" data-locale="de">March 2023</relative-time>

<!-- Embed script-->
<script type="module">
    import @joinbox/relative-time;
</script>

Components

Relative Time

Exposed Element

<relative-time></relative-time>

Attributes
  • data-time (required): A time string that can be parsed by new Date()). Relative time will be calculated in relation to the current time.
  • data-locale (optional): A BCP 47 language tag or an Intl.Locale instance (see documentation)

Events

No events are fired.

Keywords

FAQs

Package last updated on 09 Dec 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