Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Luxon is a powerful, modern, and friendly wrapper for JavaScript dates and times. It enables parsing, formatting, manipulation, and querying of dates and times in JavaScript.
DateTime Manipulation
Luxon allows for easy manipulation of DateTime objects. You can add or subtract time units, and perform other modifications.
{"DateTime": require('luxon').DateTime; let now = DateTime.now(); let later = now.plus({ hours: 3 });}
Formatting Dates
With Luxon, you can format dates according to different patterns, making it easy to display dates in a user-friendly format.
{"DateTime": require('luxon').DateTime; let now = DateTime.now(); let formatted = now.toFormat('yyyy LLL dd');}
Parsing Dates
Luxon provides functions to parse dates from strings, including ISO 8601 formats, SQL dates, and more.
{"DateTime": require('luxon').DateTime; let dt = DateTime.fromISO('2020-05-15T08:30:00');}
Internationalization
Luxon supports internationalization, allowing dates to be displayed in different languages and formats based on locale settings.
{"DateTime": require('luxon').DateTime; let now = DateTime.now(); let localized = now.setLocale('fr').toLocaleString(DateTime.DATE_FULL);}
Querying and Comparison
You can use Luxon to compare dates and times, calculate durations between them, and query properties like how many days are between two dates.
{"DateTime": require('luxon').DateTime; let now = DateTime.now(); let christmas = DateTime.local(2023, 12, 25); let daysUntilChristmas = now.until(christmas).count('days');}
Moment.js is a legacy date manipulation library that offers similar functionalities to Luxon. However, Luxon is more modern and has a better focus on immutability and internationalization.
date-fns is a modular date utility library that provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates. It's functional and has a simple API, but doesn't handle time zones as Luxon does.
Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API. It is lightweight and also does not offer time zone support out of the box like Luxon.
Luxon is a library for working with dates and times in JavaScript.
DateTime.now().setZone("America/New_York").minus({ weeks: 1 }).endOf("day").toISO();
See contributing.
3.5.0 (2024-08-03)
FAQs
Immutable date wrapper
The npm package luxon receives a total of 8,311,407 weekly downloads. As such, luxon popularity was classified as popular.
We found that luxon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.