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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gravity-ui/date-utils

v2.7.3

Published

Gravity UI date helpers

Readme

@gravity-ui/date-utils

Helpers for managing Date and Time.

Install

npm i @gravity-ui/date-utils

Usage

import {dateTimeParse, dateTime} from '@gravity-ui/date-utils';

// Current date: 2021-08-07T12:10:00
// User's time zone: Europe/Istanbul

const FORMAT = 'YYYY-MM-DDTHH:mm:ssZ';

// parse absolute date
dateTimeParse({year: 2021, month: 7, day: 7})?.format(FORMAT); // "2021-08-07T00:00:00+03:00"
dateTimeParse([2021, 7, 7])?.format(FORMAT); // "2021-08-07T00:00:00+03:00"
dateTimeParse('2021-08-07')?.format(FORMAT); // "2021-08-07T00:00:00+03:00"
dateTimeParse(1621708204063)?.format(FORMAT); // "2021-05-22T21:30:04+03:00"
dateTimeParse('')?.format(FORMAT); // undefined
dateTimeParse('incorrect-date')?.format(FORMAT); // undefined

// parse relative date
dateTimeParse('now')?.format(FORMAT); // "2021-08-07T12:10:00+03:00"
dateTimeParse('now-1d')?.format(FORMAT); // "2021-08-06T12:10:00+03:00"
dateTimeParse('now-1d+1M')?.format(FORMAT); // "2021-09-06T12:10:00+03:00"
dateTimeParse('now/d')?.format(FORMAT); // "2021-08-07T00:00:00+03:00"
dateTimeParse('now+1d/d')?.format(FORMAT); // "2021-08-08T00:00:00+03:00"
dateTimeParse('now-1f')?.format(FORMAT); // undefined

// create dateTime
dateTime().format(FORMAT); // "2021-08-07T12:10:00+03:00"
dateTime({input: '2021-08-07'}).format(FORMAT); // "2021-08-07T00:00:00+03:00"
dateTime({input: '2021-08-07', format: 'YYYY-MM-DD'}).format(FORMAT); // "2021-08-07T00:00:00+03:00"
dateTime({timeZone: 'Asia/Tokyo'}).format(FORMAT); // "2021-08-07T18:10:00+09:00
dateTime({input: ''}).format(FORMAT); // "Invalid Date"
dateTime({input: '2021-08', format: 'YYYY-MM-DD'}).format(FORMAT); // "Invalid Date"

Settings

import {settings} from '@gravity-ui/date-utils';

// Locales management
settings.getLocale(); // default locale "en"
settings.loadLocale('de').then(() => {
  settings.setLocale('de');
  settings.getLocale(); // "de"
});

// Customization
settings.updateLocale({weekStart: 0}); // change first day of week

License

Distributed under the MIT License. See LICENSE for details.

For AI agents

Timezone-aware date/time helpers — parsing (including relative expressions like now-1d/d), formatting, and locale management — without any UI, reach for it when you need to compute and format dates reliably across time zones instead of pulling in a full UI calendar.

When to use

  • Parsing absolute or relative date expressions ('now-1d', 'now/d') into a timezone-aware dateTime object.
  • Formatting dates for display in the user's timezone with locale support.
  • Sharing date logic between server (Node) and client (React) code — the package has no React dependency.

When not to use

  • To render a calendar, date picker, or any date UI, use @gravity-ui/date-components — it builds its visuals on top of this package.
  • For lightweight immutable date math and no timezone/relative-expression needs, date-fns or the native Intl/Date APIs may suffice.

Common pitfalls

  • Calling dateTimeParse('') expecting a date — returns undefined, not a dateTime; guard with optional chaining or a null check.
  • Forgetting to load a locale — settings.setLocale('de') only formats localized names (weekdays, months) after settings.loadLocale('de') has resolved.
  • Hallucinated function formatDate / parseDate — the entry points are dateTimeParse (parse) and dateTime(...).format(...) (format).
  • Assuming the user's timezone is applied automatically — pass timeZone explicitly or the system timezone is used.

Documentation for AI agents

Agent-readable documentation for the installed version is located in node_modules/@gravity-ui/date-utils/build/docs/INDEX.md.