Socket
Socket
Sign inDemoInstall

luxon

Package Overview
Dependencies
0
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

luxon

Immutable date wrapper

    3.4.4latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
7,367,260
increased by4.18%

Weekly downloads

Package description

What is luxon?

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.

What are luxon's main functionalities?

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');}

Other packages similar to luxon

Changelog

Source

3.4.4 (2023-11-12)

  • Localized week support (#1454)
  • Added custom inspect for Node (#1526)
  • Fix sorting in Interval.splitAt (#1524)

Readme

Source

Luxon

MIT License Build Status NPM version Coverage Status PRs welcome

Luxon is a library for working with dates and times in JavaScript.

DateTime.now().setZone("America/New_York").minus({ weeks: 1 }).endOf("day").toISO();

Upgrading to 3.0

Guide

Features

  • DateTime, Duration, and Interval types.
  • Immutable, chainable, unambiguous API.
  • Parsing and formatting for common and custom formats.
  • Native time zone and Intl support (no locale or tz files).

Download/install

Download/install instructions

Documentation

Development

See contributing.

Phasers to stun

Keywords

FAQs

Last updated on 12 Nov 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the 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