Socket
Socket
Sign inDemoInstall

@js-joda/core

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@js-joda/core

a date and time library for javascript


Version published
Weekly downloads
1.8M
increased by21.39%
Maintainers
2
Weekly downloads
 
Created

What is @js-joda/core?

@js-joda/core is a JavaScript library for working with dates and times. It is a port of the Joda-Time library from Java, providing a comprehensive and immutable date and time API for JavaScript. The library is designed to be easy to use and to provide a consistent and reliable way to handle date and time operations.

What are @js-joda/core's main functionalities?

Creating Dates and Times

This feature allows you to create instances of LocalDate, LocalTime, and LocalDateTime representing the current date, time, and date-time respectively.

const { LocalDate, LocalTime, LocalDateTime } = require('@js-joda/core');

const date = LocalDate.now();
const time = LocalTime.now();
const dateTime = LocalDateTime.now();

console.log(date.toString()); // e.g., 2023-10-05
console.log(time.toString()); // e.g., 14:30:00.123
console.log(dateTime.toString()); // e.g., 2023-10-05T14:30:00.123

Parsing and Formatting

This feature allows you to parse date strings into LocalDate objects using a specified pattern and format LocalDate objects back into strings.

const { LocalDate, DateTimeFormatter } = require('@js-joda/core');

const dateString = '2023-10-05';
const formatter = DateTimeFormatter.ofPattern('yyyy-MM-dd');
const date = LocalDate.parse(dateString, formatter);

console.log(date.toString()); // 2023-10-05

Date Arithmetic

This feature allows you to perform arithmetic operations on dates, such as adding or subtracting days, weeks, months, or years.

const { LocalDate } = require('@js-joda/core');

const date = LocalDate.of(2023, 10, 5);
const nextWeek = date.plusWeeks(1);
const previousMonth = date.minusMonths(1);

console.log(nextWeek.toString()); // 2023-10-12
console.log(previousMonth.toString()); // 2023-09-05

Comparing Dates and Times

This feature allows you to compare dates and times to determine if one is before, after, or equal to another.

const { LocalDate } = require('@js-joda/core');

const date1 = LocalDate.of(2023, 10, 5);
const date2 = LocalDate.of(2023, 10, 6);

console.log(date1.isBefore(date2)); // true
console.log(date1.isAfter(date2)); // false
console.log(date1.equals(date2)); // false

Other packages similar to @js-joda/core

Keywords

FAQs

Package last updated on 06 Jul 2020

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