npm.io
1.0.0 • Published 3d ago

tiny-date-fns

Licence
MIT
Version
1.0.0
Deps
0
Size
18 kB
Vulns
0
Weekly
0

tiny-date-utils

A lightweight, zero-dependency library for common date operations.

Installation

npm install tiny-date-utils

Usage

import { timeAgo, formatDate, daysBetween, isWeekend } from 'tiny-date-utils';

timeAgo(Date.now() - 3600000);  // '1h ago'
formatDate(new Date(), 'DD/MM/YYYY');  // '15/01/2024'
daysBetween(new Date(2024,0,1), new Date(2024,0,11));  // 10
isWeekend(new Date());  // true/false

Available Functions

  • timeAgo(date) — Human-readable relative time
  • formatDate(date, format?) — Format with YYYY/MM/DD/HH/mm/ss tokens
  • isToday(date) — Check if date is today
  • daysBetween(a, b) — Days between two dates
  • addDays(date, days) — Add days to a date
  • startOfDay(date) / endOfDay(date) — Day boundaries
  • isWeekend(date) — Check Saturday/Sunday
  • dateDiff(a, b) — Detailed difference (days, hours, minutes, seconds)

Keywords