Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
intl-relativeformat
Advanced tools
The intl-relativeformat npm package is used for formatting relative dates and times in a human-readable way. It leverages the Internationalization API to provide locale-aware formatting, making it easier to display dates and times relative to the current date and time.
Basic Relative Time Formatting
This feature allows you to format a date relative to the current time. In this example, it formats a date that is one hour ago.
const IntlRelativeFormat = require('intl-relativeformat');
const rf = new IntlRelativeFormat('en');
console.log(rf.format(Date.now() - 1000 * 60 * 60)); // 'an hour ago'
Locale-Specific Formatting
This feature allows you to format dates relative to the current time in a locale-specific manner. In this example, it formats a date that is one hour ago in French.
const IntlRelativeFormat = require('intl-relativeformat');
const rf = new IntlRelativeFormat('fr');
console.log(rf.format(Date.now() - 1000 * 60 * 60)); // 'il y a une heure'
Future Date Formatting
This feature allows you to format future dates relative to the current time. In this example, it formats a date that is one hour in the future.
const IntlRelativeFormat = require('intl-relativeformat');
const rf = new IntlRelativeFormat('en');
console.log(rf.format(Date.now() + 1000 * 60 * 60)); // 'in an hour'
Moment.js is a widely-used library for parsing, validating, manipulating, and formatting dates. It provides relative time formatting through its `fromNow` and `toNow` methods. Compared to intl-relativeformat, Moment.js offers a broader range of date manipulation features but is larger in size.
date-fns is a modern JavaScript date utility library that provides a variety of functions for working with dates, including relative time formatting through its `formatDistance` and `formatDistanceToNow` functions. It is modular and tree-shakeable, making it a lightweight alternative to Moment.js.
Luxon is a modern JavaScript library for working with dates and times, created by one of the Moment.js developers. It provides relative time formatting through its `toRelative` and `toRelativeCalendar` methods. Luxon is built on top of the native JavaScript Internationalization API, similar to intl-relativeformat, but offers a more comprehensive set of features.
Formats JavaScript dates to relative time strings.
FAQs
Formats JavaScript dates to relative time strings.
The npm package intl-relativeformat receives a total of 120,001 weekly downloads. As such, intl-relativeformat popularity was classified as popular.
We found that intl-relativeformat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.