@rightcapital/date-helpers
TypeScript icon, indicating that this package has built-in type declarations

3.1.19 • Public • Published

@rightcapital/date-helpers

A utility class providing various date formatting and parsing methods in TypeScript.

Features

  • Convert a date string to Date object with parseDateString.
  • Format dates into various string formats, such as ISO, US locale, and more.
  • Handle a variety of date string formats for both parsing and formatting.

Installation

pnpm add @rightcapital/date-helpers

Usage

Parse Date String

Convert a date string to a Date object using various possible formats.

import { DateHelpers } from '@rightcapital/date-helpers';
const date = DateHelpers.parseDateString('2023/01/01');

Format to ISO Date String

Format a date as an ISO date string.

import { DateHelpers } from '@rightcapital/date-helpers';

const isoDateString = DateHelpers.formatDateLikeToIsoDateString(
  new Date(2023, 0, 1),
);
// Result: Sun Jan 01 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Format to US Locale

Format a date as a US locale date string.

import { DateHelpers } from '@rightcapital/date-helpers';
const usDateString = DateHelpers.formatDateLikeToUsLocaleDateString(
  new Date(2023, 0, 31),
);
// Result: "01/31/2023"

Formats a date as a US locale time string.

import { DateHelpers } from '@rightcapital/date-helpers';
const usDateString = DateHelpers.formatDateLikeToUsLocaleDateTimeString(
  '2025/10/20 12:00:00',
);
// Result: "10/20/2025 12:00:00"

Format to US Locale Medium Date

Formats a date as a string in the MDY format.

const monthDayYearString = DateHelpers.formatDateLikeToUsLocaleMediumDateString(
  new Date(2023, 0, 1),
);
// Result: "Jan 1, 2023"

API Reference

Here is the API documentation for the modules included in the package.

Package Sidebar

Install

npm i @rightcapital/date-helpers

Weekly Downloads

552

Version

3.1.19

License

MIT

Unpacked Size

19.5 kB

Total Files

6

Last publish

Collaborators

  • rightcapital-npm-publisher
  • hao.zheng
  • rainxright