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

@kota-dev/tiny-date-utils

v1.1.1

Published

Tiny safe date formatters (YYYY-MM-DD / YYYY/MM/DD).

Readme

tiny-date-utils

小さくて安全な日付フォーマッター。
Date を複数の形式に整形します("YYYY-MM-DD", "YYYY/MM/DD", "YYYY年M月D日(曜)", "YYYY-MM-DD HH:mm:ss")。
不正な値(null / undefined / Invalid Date)は 空文字 "" を返します。

対応環境

  • Node.js 20+
  • TypeScript 5+ / ESM

インストール

npm i @kota-dev/tiny-date-utils

クイックスタート

// TypeScript / ESM
import {
  formatDateYYYYMMDD,
  formatDateYYYYslashMMslashDD,
  formatJapaneseDate,
  formatDateTimeYYYYMMDDHHmmss,
} from '@kota-dev/tiny-date-utils';

const d = new Date('2025-09-06T10:30:00Z');

formatDateYYYYMMDD(d); // "2025-09-06"
formatDateYYYYslashMMslashDD(d); // "2025/09/06"
formatJapaneseDate(d); // "2025年9月6日(金)"
formatDateTimeYYYYMMDDHHmmss(d); // "2025-09-06 19:30:00" (JST例)

formatDateYYYYMMDD(null); // ""
formatDateYYYYslashMMslashDD(new Date('invalid')); // ""
formatJapaneseDate(null); // ""
formatDateTimeYYYYMMDDHHmmss(undefined); // ""

API

formatDateYYYYMMDD(d: Date | null | undefined): string

  • 例: 2025-09-06
  • 引数が不正な場合は "" を返します。

formatDateYYYYslashMMslashDD(d: Date | null | undefined): string

  • 例: 2025/09/06
  • 引数が不正な場合は "" を返します。

formatJapaneseDate(d: Date | null | undefined): string

  • 例: 2025年9月6日(金)
  • 日本語形式で日付と曜日を表示します。
  • 引数が不正な場合は "" を返します。

formatDateTimeYYYYMMDDHHmmss(d: Date | null | undefined): string

  • 例: 2025-09-06 19:30:00
  • 日付と時刻を含む形式で表示します。
  • 引数が不正な場合は "" を返します。

挙動と注意点

  • ローカルタイムで整形します(getFullYear() / getMonth() / getDate() を使用)。
    • 例: new Date('2025-09-06T10:30:00Z')環境のタイムゾーンにより表示される日付が前後する可能性があります。
    • UTC での整形が必要な場合は将来の拡張(formatDateUTCYYYYMMDD など)を検討しています。
  • 不正な値(null / undefined / Invalid Date)は 例外を投げず空文字を返します。
    フォーム表示やログ出力での安心運用のための方針です。

なぜこれ?

  • 超軽量:日付フォーマットだけ。大きな日付ライブラリは不要。
  • 安全ガード込み:毎回バリデーションを書く手間を削減。
  • 学習コストゼロ:関数4つだけ覚えればOK。
  • 多様な形式対応:英語形式から日本語形式、日時形式まで幅広くカバー。

開発(このリポジトリをクローンして使う場合)

# ビルド
npm run build

# Lint
npm run lint

# Prettier で整形
npm run format

# テスト
npm run test
npm run coverage
  • TypeScript 型定義(.d.ts)付きで dist/ に出力されます。

Roadmap

  • UTC 版フォーマッター(formatDateUTCYYYYMMDD など)
  • パターン指定型 formatDate(d, 'yyyy-mm-dd') の提供(後方互換を保ちながら)
  • より多くの時刻フォーマット(12時間制など)

ライセンス

CC0-1.0 — see LICENSE