datemapper
Version:
A lightweight date utility for format conversion, validation, and date manipulation.
27 lines (25 loc) • 1.07 kB
text/typescript
/**
* Defines supported date format types for conversion functions.
* These formats represent commonly used date formats.
*/
export type DateFormatType =
| "%Y-%m-%d" // Example: 2025-02-24
| "YYYY-MM-DD" // Example: 2025-02-24 (Standard ISO format)
| "%m/%d/%Y" // Example: 02/24/2025
| "MM/DD/YYYY" // Example: 02/24/2025 (US format)
| "%d-%m-%Y" // Example: 24-02-2025 (European format)
| "DD-MM-YYYY" // Example: 24-02-2025 (European format)
| "%Y/%m/%d" // Example: 2025/02/24
| "YYYY/MM/DD"; // Example: 2025/02/24 (Alternative format)
/**
* Defines allowed time units for date manipulation functions.
* These units specify how dates can be incremented or decremented.
*/
export type TIncrementType =
| "day" // Increment or decrement by a day
| "month" // Increment or decrement by a month
| "hour" // Increment or decrement by an hour
| "year" // Increment or decrement by a year
| "week" // Increment or decrement by a week
| "minute" // Increment or decrement by a minute
| "second"; // Increment or decrement by a second