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

@connect-soft/date-helper

v0.0.10

Published

A TypeScript date manipulation library built on top of Day.js, providing a fluent API for working with dates, times, and locales

Readme

Date Helper

A TypeScript date manipulation library built on top of Day.js, providing a fluent API for working with dates, times, and locales.

Installation

npm install @connect-soft/date-helper dayjs
pnpm add @connect-soft/date-helper dayjs
yarn add @connect-soft/date-helper dayjs

Note: dayjs is a peer dependency and must be installed separately.

Features

  • Fluent API for date manipulation
  • Immutable or mutable operations (configurable)
  • Timezone support
  • Locale-aware formatting
  • Type-safe with TypeScript
  • Lightweight wrapper around Day.js
  • Support for both ESM and CommonJS

Basic Usage

import { DateHelper } from '@connect-soft/date-helper';

// Create from current time
const now = DateHelper.now();

// Create from Date object
const date = DateHelper.from(new Date());

// Create from string
const parsed = DateHelper.fromDateTimeString('2024-10-02T08:11:00Z');

// Create from null (safe handling)
const nullable = DateHelper.from(null);

API Reference

Static Methods

DateHelper.now()

Creates a DateHelper instance with the current date and time.

const now = DateHelper.now();

DateHelper.from(source)

Creates a DateHelper instance from a Date, Dayjs object, or null.

const date = DateHelper.from(new Date());
const fromDayjs = DateHelper.from(dayjs());
const fromNull = DateHelper.from(null); // Returns DateHelper with null instance

DateHelper.fromDateTimeString(source)

Creates a DateHelper instance from a date-time string.

const date = DateHelper.fromDateTimeString('2024-10-02T08:11:00Z');

DateHelper.addHours(source, hours)

Static utility to add hours to a date.

const result = DateHelper.addHours(new Date(), 2);

Instance Methods

Date Manipulation

// Add days (immutable by default)
const tomorrow = DateHelper.now().addDays(1, false);

// Add hours (mutable if update=true)
const later = DateHelper.now().addHours(2, true);

// Get start of day
const startOfDay = DateHelper.now().getStartOfDay();

// Get end of day
const endOfDay = DateHelper.now().getEndOfDay();

Comparison

const date1 = DateHelper.now();
const date2 = DateHelper.now().addDays(1);

// Check if after
if (date2.isAfter(date1)) {
  console.log('date2 is after date1');
}

// Check if equal
if (date1.isEqual(date1, 'day')) {
  console.log('Same day');
}

// Calculate difference
const hoursDiff = date2.diff(date1, 'hours'); // Returns number

Formatting

const date = DateHelper.now();

// Custom format using Day.js format
const formatted = date.format('YYYY-MM-DD HH:mm:ss');

// Locale-aware date formatting
const localDate = date.formatLocalDate('en-US'); // "1/15/2024"
const czechDate = date.formatLocalDate('cs'); // "15. 1. 2024"

// Locale-aware time formatting
const time = date.formatLocalTime('en-US'); // "2:30 PM"

// Locale-aware date-time formatting
const dateTime = date.formatLocalDateTime('cs'); // "15. 1. 2024 14:30"

// Custom locale options
const customFormat = date.formatLocalDate('en-US', {
  weekday: 'long',
  year: 'numeric',
  month: 'long',
  day: 'numeric'
}); // "Monday, January 15, 2024"

Locale Management

// Get current locale
const locale = DateHelper.now().getLocale(); // "en"

// Set locale (requires importing locale first)
import 'dayjs/locale/cs';
const czechDate = DateHelper.now().setLocale('cs');

Conversion

// Convert to Date object
const dateObj = DateHelper.now().toDate();

// Get underlying Day.js instance
const dayjsObj = DateHelper.now().getObj();

Advanced Examples

Working with Timezones

import { DateHelper } from '@connect-soft/date-helper';

// The library includes timezone plugin by default
const date = DateHelper.fromDateTimeString('2024-01-15T14:30:00Z');

Null-Safe Operations

// All methods handle null gracefully
const nullable = DateHelper.from(null);
nullable.addDays(5).toDate(); // Returns null
nullable.format('YYYY-MM-DD', 'N/A'); // Returns 'N/A'
nullable.formatLocalDate('en-US'); // Returns ""

Chaining Operations

const result = DateHelper.now()
  .addDays(7)
  .getStartOfDay()
  .addHours(9)
  .format('YYYY-MM-DD HH:mm');

TypeScript Support

This library is written in TypeScript and includes full type definitions.

import { DateHelper, IDateTimeType } from '@connect-soft/date-helper';

// IDateTimeType is an alias for Day.js Dayjs type
const dayjs: IDateTimeType = DateHelper.now().getObj();

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Repository

GitLab Repository