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

trading-date-time

v0.1.0

Published

Interface for timezone-aware trading timestamp with market calendar support

Readme

Trading Date Time

Interface for timezone-aware trading timestamp with market calendar support

Overview

Trading Date Time is a TypeScript library that provides timezone-aware trading time functionality designed specifically for financial markets. Unlike standard date/time libraries, this module understands trading calendars, market hours, and business day calculations essential for trading applications.

Features

  • Built on Luxon Foundation: Powered by Luxon's proven date/time engine for reliability and performance
  • Trading Domain Awareness: Knows about market holidays, early close days, and trading sessions
  • Timezone Handling: Automatically handles market-specific timezones (e.g., America/New_York for US equities)
  • Business Day Navigation: Provides next/previous trading day functionality
  • Trading Hours Validation: Validates trading hours for different session types

Installation

npm install trading-date-time

Quick Start

import { MarketsTime } from 'trading-date-time';

// Create a trading timestamp for US Equities market
const marketOpen = MarketsTime.USEquities.fromISO('2024-03-15T09:30:00');

// Check if it's a trading day
console.log(marketOpen.isOnTradingDay()); // true

// Get the date string
console.log(marketOpen.toISODate()); // "2024-03-15"

// Navigate to next trading day
const nextTradingDay = marketOpen.toNextTradingDay();
console.log(nextTradingDay.toISODate());

API Reference

MarketsTime

Primary registry for creating market-specific instances.

MarketsTime.USEquities

Factory for US Equities market (America/New_York timezone).

// Create from ISO string
const time = MarketsTime.USEquities.fromISO('2024-03-15T09:30:00');

// Create from milliseconds
const time = MarketsTime.USEquities.fromMillis(1710504600000);

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

TradingDateTime Interface

interface TradingDateTime {
  // Trading-specific methods
  isOnTradingDay(): boolean;
  toNextTradingDay(): TradingDateTime;
  toPreviousTradingDay(): TradingDateTime;

  // Date/time methods
  toISODate(): string | null;
  toMillis(): number;

  // Comparison methods
  equals(other: TradingDateTime): boolean;
  // ... and more
}

Trading Hours

import { MarketsTime, REGULAR_HOURS, EXTENDED_HOURS } from 'trading-date-time';

const time = MarketsTime.USEquities.fromISO('2024-04-12T07:00:00');

// Check different trading sessions
console.log(time.isDuringTradingHours(REGULAR_HOURS));   // false (pre-market)
console.log(time.isDuringTradingHours(EXTENDED_HOURS));  // true (extended hours)

Supported Markets

Currently supports:

  • US Equities: America/New_York timezone with full holiday and early close calendar

Requirements

  • Node.js 16 or higher
  • TypeScript 4.5 or higher (for TypeScript projects)

Dependencies

  • Luxon - Mature, powerful, and friendly wrapper for JavaScript dates and times

License

MIT

Contributing

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