npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pqdate

v1.0.1

Published

pqDate - Minimal, predictable, UTC-first date library (monorepo)

Readme

pqDate — Minimal, predictable, UTC-first date library

Descripción

  • UTC-first, immutable operations with month/year EOM safety

  • Predictable API: parseISO, formatISO, add, sub, startOf, endOf, comparisons

  • Localized output via Intl for es-ES and en-US

  • Business rule: lastBusinessDayOfMonth

  • Modular, tree-shakable, no heavy deps, works in Node and browsers (UMD)

  • Operaciones inmutables con prioridad UTC y seguridad de fin de mes/año

  • API predecible: parseISO, formatISO, add, sub, startOf, endOf, comparaciones

  • Salida localizada mediante Intl para es-ES y en-US

  • Regla de negocio: último día hábil del mes

  • Modular, optimizable mediante tree shaking, sin dependencias pesadas, compatible con Node y navegadores (UMD)

Instalar

  • npm: npm install pqdate
  • Import ESM: import { add, parseISO } from 'pqdate'
  • UMD: dist/pqdate.umd.js expone el global pqDate

Quick Start import { parseISO, add, formatISO } from 'pqdate'; const d = parseISO('2025-01-31T00:00:00Z'); const n = add(d, { months: 1 }); console.log(formatISO(n)); // 2025-02-28T00:00:00.000Z

API

  • Core

    • parseISO(input: string): Date
    • formatISO(d: Date): string
    • type Duration = Partial<{ years; months; days; hours; minutes; seconds }>
    • add(d: Date, dur: Duration): Date
    • sub(d: Date, dur: Duration): Date
    • startOf(d: Date, unit: 'day'|'month'|'year'): Date
    • endOf(d: Date, unit: 'day'|'month'|'year'): Date
    • isBefore(a: Date, b: Date): boolean
    • isAfter(a: Date, b: Date): boolean
    • isWithinInterval(d: Date, itv:{start:Date,end:Date}): boolean
    • differenceInDays(a: Date, b: Date): number
    • isSame(a: Date, b: Date, unit: 'day'|'month'|'year'): boolean
    • assertValid(d: Date): void
    • toLocal(dUTC: Date): Date
  • Intl

    • formatLocal(d: Date, opts?: { locale?: 'es-ES'|'en-US', dateStyle?: 'short'|'medium'|'long', timeStyle?: 'short'|'medium'|'long' }): string
  • Rules

    • lastBusinessDayOfMonth(d: Date): Date

Design Notes

  • Inmutability: all functions return new Date instances

  • UTC policy: all arithmetic and truncation use UTC getters/setters

  • toLocal: returns a Date constructed with the original UTC components as local wall time

  • Validation: invalid inputs/intervals throw PqDateError with codes: E_PARSE_INVALID, E_RANGE, E_ARG_INVALID

  • Inmutabilidad: todas las funciones devuelven nuevas instancias de Date.

  • Política UTC: todas las operaciones aritméticas y de truncamiento utilizan los métodos getter/setter de UTC.

  • toLocal: devuelve un objeto Date construido con los componentes UTC originales como hora local.

  • Validación: las entradas o intervalos no válidos generan una excepción PqDateError con los códigos: E_PARSE_INVALID, E_RANGE, E_ARG_INVALID.

Build

  • tsup builds ESM/CJS/UMD into dist/
  • size-limit enforces core bundle ≤ 20KB gzip
  • Tests: vitest under tests/

Examples

  • examples/browser-umd: plain script with global pqDate
  • examples/esm: simple ESM usage

Ejemplos rápidas

  • Rango de hoy a fin de mes
import { startOf, endOf, parseISO, formatISO } from 'pqdate';

const hoy = new Date();
const inicioHoy = startOf(hoy, 'day');
const finMes = endOf(hoy, 'month');
console.log(formatISO(inicioHoy), formatISO(finMes));
  • Sumar meses respetando fin de mes
import { parseISO, add, formatISO } from 'pqdate';

const d = parseISO('2025-01-31T00:00:00Z');
console.log(formatISO(add(d, { months: 1 }))); // 2025-02-28T00:00:00.000Z
  • Diferencia en días (UTC, truncado a inicio de día)
import { differenceInDays, parseISO } from 'pqdate';

const a = parseISO('2025-03-02T10:00:00Z');
const b = parseISO('2025-03-01T23:59:59Z');
console.log(differenceInDays(a, b)); // 1
  • ¿Mismo día/mes/año?
import { isSame, parseISO } from 'pqdate';

const a = parseISO('2025-03-15T00:00:00Z');
const b = parseISO('2025-03-15T23:59:59Z');
console.log(isSame(a, b, 'day')); // true
  • Último día hábil del mes
import { lastBusinessDayOfMonth, parseISO, formatISO } from 'pqdate';

const d = parseISO('2025-03-01T00:00:00Z');
console.log(formatISO(lastBusinessDayOfMonth(d))); // 2025-03-31T00:00:00.000Z
  • Mostrar hora “de pared” local a partir de un UTC
import { toLocal, parseISO } from 'pqdate';

const utc = parseISO('2025-01-31T12:34:56Z');
const local = toLocal(utc);
// Los componentes locales de 'local' coinciden con los UTC de 'utc'