Skip to content

tetherto/pear-apps-utils-date

Repository files navigation

pear-apps-utils-date

A collection of date utility functions for formatting and comparing dates.

Table of Contents

Features

  • Format dates with customizable patterns using formatDate
  • Compare dates with isAfter to check if one date is later than another
  • Compare dates with isBefore to check if one date is earlier than another
  • Support for both Date objects and string date inputs
  • Customizable date separators
  • Month and weekday abbreviations

Security Notice

  1. To ensure the security and integrity of your projects, please note that official PearPass packages are distributed exclusively through our GitHub organization.
  2. Any packages with similar names found on the npm registry or other third-party package managers are not affiliated with PearPass and should be strictly avoided. We recommend installing directly from this repository to ensure you are using the verified, open-source version.

Installation

npm install git+https://github.com/tetherto/pear-apps-utils-date.git

Usage

Import the functions you need:

import { formatDate, isAfter, isBefore } from '@tetherto/pear-apps-utils-date';

Examples

Format Dates

// Basic formatting (default: yyyy-mm-dd)
formatDate(new Date('2023-05-15'));
// Output: '2023-05-15'

// Custom format
formatDate(new Date('2023-05-15'), 'dd-mm-yyyy');
// Output: '15-05-2023'

// Custom separator
formatDate(new Date('2023-05-15'), 'yyyy-mm-dd', '/');
// Output: '2023/05/15'

// With month abbreviation
formatDate(new Date('2023-05-15'), 'dd-mmm-yyyy');
// Output: '15-May-2023'

// With weekday abbreviation
formatDate(new Date('2023-05-15'), 'ddd-mm-dd');
// Output: 'Mon-05-15'

Compare Dates

// Check if a date is after another
isAfter('2023-01-02', '2023-01-01');
// Output: true

// Check if a date is before another
isBefore('2023-01-01', '2023-01-02');
// Output: true

Dependencies

This package has no runtime dependencies.

Related Projects

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

About

PearPass is an open-source, privacy-first password manager with peer-to-peer syncing and end-to-end encryption. This repository contains shared core components used across the PearPass apps.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors