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

0.0.2 • Public • Published

@type-ddd/date

The @type-ddd/date library provides a class Dates for handling date and time operations in TypeScript. It offers various methods for manipulating dates, calculating differences, formatting dates, and checking validity. This library aims to simplify date and time management in Domain-Driven Design contexts.


Installation

Install rich-domain and @type-ddd/date with your favorite package manager:

npm i rich-domain @type-ddd/date

# OR

yarn add rich-domain @type-ddd/date

Usage

import { Dates } from '@type-ddd/dates';

// Check if is valid value
const isValid = Dates.isValid('2020-02-31');
// false

// Initialize Dates instance with current date and time
const date = Dates.init();

// OR

// Create Dates instance from provided date or timestamp
const result = Dates.create('2024-05-24');

// Add days, months, hours, minutes, weeks, or years
const newDate = date.addDays(5).addMonths(2);

// Format date according to various patterns
const formattedDate = date.format('DD/MM/YYYY hh:mm:ss');

// Check if date is weekday or weekend
const isWeekday = date.isWeekday();
const isWeekend = date.isWeekend();

Package Sidebar

Install

npm i @type-ddd/date

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

48.5 kB

Total Files

9

Last publish

Collaborators

  • alessandro-dev