Lightweight date/time formatting and manipulation
Find a file
2026-01-05 02:45:04 +02:00
.github/workflows Add React-based website build and update deployment workflow 2026-01-05 02:45:04 +02:00
docs init 2026-01-05 00:02:56 +02:00
src init 2026-01-05 00:02:56 +02:00
tests init 2026-01-05 00:02:56 +02:00
website Add React-based website build and update deployment workflow 2026-01-05 02:45:04 +02:00
.gitignore init 2026-01-05 00:02:56 +02:00
.npmignore init 2026-01-05 00:02:56 +02:00
.prettierrc init 2026-01-05 00:02:56 +02:00
CHANGELOG.md init 2026-01-05 00:02:56 +02:00
eslint.config.js init 2026-01-05 00:02:56 +02:00
LICENSE init 2026-01-05 00:02:56 +02:00
package-lock.json init 2026-01-05 00:02:56 +02:00
package.json Add React-based website build and update deployment workflow 2026-01-05 02:45:04 +02:00
README.md init 2026-01-05 00:02:56 +02:00
timekit-claude-code-prompt.md init 2026-01-05 00:02:56 +02:00
tsconfig.json init 2026-01-05 00:02:56 +02:00
tsup.config.ts init 2026-01-05 00:02:56 +02:00
vitest.config.ts init 2026-01-05 00:02:56 +02:00

TimeKit

Lightweight date/time formatting and manipulation

WebsiteRepositoryAPI Docs

npm version bundle size license Tests Coverage


Features

  • Formatting - Flexible date/time patterns
  • Parsing - Multiple input formats
  • Relative Time - "2 hours ago"
  • Manipulation - Add, subtract, chainable
  • Comparison - Before, after, between
  • Duration - Format and humanize
  • Timezone - Convert and handle DST
  • Calendar - Grid generation
  • Immutable - Predictable operations
  • React - Hooks & components
  • Zero Dependencies
  • < 3KB - Tiny bundle

Installation

npm install @oxog/timekit

Quick Start

import { createTime, now } from '@oxog/timekit'

// Format
now().format('MMMM D, YYYY')  // 'January 4, 2026'

// Relative
createTime('2026-01-02').fromNow()  // '2 days ago'

// Manipulate
now().add(1, 'week').startOf('day')

// Compare
now().isBefore('2026-02-01')  // true

React

import { useNow, useCountdown, TimeAgo } from '@oxog/timekit/react'

// Live clock
const time = useNow({ interval: 1000, format: 'HH:mm:ss' })

// Countdown
const { days, hours, minutes, seconds } = useCountdown('2026-02-01')

// Relative time component
<TimeAgo date={post.createdAt} />

Testing

TimeKit comes with comprehensive test coverage:

  • 511 tests covering all core functionality
  • 71.84% code coverage with v8 reporter
  • 100% success rate across all test suites

Test suites include:

  • Time manipulation (add, subtract, startOf, endOf)
  • Formatting and parsing
  • Timezone conversions (IANA database)
  • Duration calculations and humanization
  • Calendar utilities and generation
  • Validation utilities
  • Configuration management
  • Internationalization (locales)
  • React hooks and components

Run tests with:

npm test                # Run all tests
npm run test:coverage   # Generate coverage report
npm run test:ui         # Interactive test UI

Documentation

License

MIT © Ersin KOÇ