@ponado/date-utils (0.0.11)

Published 2026-06-01 16:38:51 +03:00 by adomas

Installation

@ponado:registry=
npm install @ponado/date-utils@0.0.11
"@ponado/date-utils": "0.0.11"

About this package

@ponado/date-utils

Date utilities for TypeScript with Lithuanian localization support.

Installation

pnpm add @ponado/date-utils

Usage

import {
	calculateAge,
	getVerbalDate,
	getDifferenceInDays,
	getDaysUntilAnniversary,
	formatDaysDifference
} from '@ponado/date-utils';

// Calculate age
const age = calculateAge(new Date('1990-05-15'));

// Format date in Lithuanian
const verbal = getVerbalDate(new Date()); // "2024 m. gegužės 9 d."

// Days between dates
const days = getDifferenceInDays(date1, date2);

// Days until next birthday
const daysUntil = getDaysUntilAnniversary(birthDate);

// Human-readable difference
const text = formatDaysDifference(5); // "5 d."
const text = formatDaysDifference(0); // "šiandien"
const text = formatDaysDifference(-1); // "vakar"

API

calculateAge(birthDate, today?)

Calculate age in full years.

getVerbalDate(date)

Format date as "YYYY m. MonthName DD d." in Lithuanian.

getDifferenceInDays(date1, date2)

Calculate absolute difference in days between two dates.

getDaysUntilAnniversary(date, now?)

Get days until the next occurrence of a date (e.g., birthday).

formatDaysDifference(diffDays)

Convert day difference to human-readable Lithuanian string.

  • -1"vakar" (yesterday)
  • 0"šiandien" (today)
  • 1"rytoj" (tomorrow)
  • < 30"N d." (N days)
  • < 365"N mėn." (N months)
  • >= 365"N m." (N years)

getAnniversaryDate(eventDate, now?)

Get the next anniversary date.

getYearsOnAnniversary(anniversaryDate, now?)

Get number of years that will be celebrated on next anniversary.

normalizeToUTC(date)

Normalize a Date to midnight UTC.

Dependencies

Development dependencies

ID Version
@types/node ^20.19.40
bumpp ^11.1.0
tsdown ^0.21.10
typescript ^6.0.3
vitest ^1.6.1
Details
npm
2026-06-01 16:38:51 +03:00
8
Adomas Poniškaitis
MIT
latest
2.8 KiB
Assets (1)
Versions (4) View all
0.0.11 2026-06-01
0.0.10 2026-06-01
0.0.8 2026-05-09
0.0.1 2026-04-30