|
| 1 | +--- |
| 2 | +title: date-and-time |
| 3 | +description: The simplest, most intuitive date and time library |
| 4 | +template: splash |
| 5 | +hero: |
| 6 | + title: date-and-time |
| 7 | + tagline: The simplest, most intuitive date and time library. Modern TypeScript library for date manipulation with full ES Modules support. |
| 8 | + image: |
| 9 | + src: /date-and-time/logo.png |
| 10 | + alt: date-and-time |
| 11 | + actions: |
| 12 | + - text: Get Started |
| 13 | + link: /date-and-time/guide/ |
| 14 | + icon: right-arrow |
| 15 | + variant: primary |
| 16 | + - text: API Reference |
| 17 | + link: /date-and-time/api/ |
| 18 | + variant: minimal |
| 19 | + - text: View on GitHub |
| 20 | + link: https://github.com/knowledgecode/date-and-time |
| 21 | + icon: external |
| 22 | + variant: minimal |
| 23 | +--- |
| 24 | + |
| 25 | +import { Card, CardGrid, Tabs, TabItem } from '@astrojs/starlight/components'; |
| 26 | + |
| 27 | +## Features |
| 28 | + |
| 29 | +<CardGrid> |
| 30 | + <Card title="Modern & Fast" icon="rocket"> |
| 31 | + Written in TypeScript with ES2021 target. Tree-shakable modules for optimal bundle size. |
| 32 | + </Card> |
| 33 | + <Card title="Internationalization" icon="translate"> |
| 34 | + Support for 40+ locales and multiple calendar systems. Arabic, Bengali, Myanmar numerals. |
| 35 | + </Card> |
| 36 | + <Card title="Timezone Support" icon="moon"> |
| 37 | + Complete timezone handling with IANA timezone database built-in. |
| 38 | + </Card> |
| 39 | + <Card title="Type Safe" icon="approve-check"> |
| 40 | + Full TypeScript support with comprehensive type definitions and IntelliSense. |
| 41 | + </Card> |
| 42 | + <Card title="Tree Shakable" icon="puzzle"> |
| 43 | + Import only what you need. Optimized for modern bundlers with sideEffects false. |
| 44 | + </Card> |
| 45 | + <Card title="Plugin System" icon="add-document"> |
| 46 | + Extensible plugin system allows you to extend formatters and parsers. |
| 47 | + </Card> |
| 48 | +</CardGrid> |
| 49 | + |
| 50 | +## Quick Example |
| 51 | + |
| 52 | +```typescript |
| 53 | +import { format, parse, addDays } from 'date-and-time'; |
| 54 | +import ja from 'date-and-time/locales/ja'; |
| 55 | + |
| 56 | +const now = new Date(); |
| 57 | + |
| 58 | +// Basic formatting |
| 59 | +format(now, 'YYYY/MM/DD HH:mm:ss'); |
| 60 | +// => 2025/08/23 14:30:45 |
| 61 | + |
| 62 | +// Localized formatting |
| 63 | +format(now, 'YYYY年M月D日(ddd)', { locale: ja }); |
| 64 | +// => 2025年8月23日(金) |
| 65 | + |
| 66 | +// Timezone-aware formatting |
| 67 | +format(now, 'YYYY-MM-DD HH:mm:ss [EST]', { timeZone: 'America/New_York' }); |
| 68 | +// => 2025-08-23 09:30:45 EST |
| 69 | + |
| 70 | +// Parsing |
| 71 | +const date = parse('2025/08/23 14:30:45', 'YYYY/MM/DD HH:mm:ss'); |
| 72 | +console.log(date) |
| 73 | + |
| 74 | +// Date arithmetic |
| 75 | +const futureDate = addDays(now, 7); |
| 76 | +console.log(format(futureDate, 'YYYY/MM/DD')); |
| 77 | +``` |
| 78 | + |
| 79 | +## Key Features in v4.x |
| 80 | + |
| 81 | +- **Complete TypeScript rewrite** with enhanced type safety |
| 82 | +- **Tree-shaking support** for better bundle optimization |
| 83 | +- **Integrated timezone and timespan plugins** into the core library |
| 84 | +- **Modern JavaScript** targeting ES2021 (Node.js ≥18 required) |
| 85 | +- **Enhanced API** with options objects instead of boolean flags |
| 86 | +- **Improved locale handling** with per-function locale specification |
| 87 | + |
| 88 | +## Browser & Environment Support |
| 89 | + |
| 90 | +- **Node.js**: 18+ |
| 91 | +- **Browsers**: Chrome 85+, Firefox 78+, Safari 14+, Edge 85+ |
| 92 | +- **Module Systems**: ES Modules, CommonJS |
| 93 | +- **TypeScript**: 4.5+ |
| 94 | + |
| 95 | +## Installation |
| 96 | + |
| 97 | +<Tabs> |
| 98 | +<TabItem label="npm"> |
| 99 | +```bash |
| 100 | +npm install date-and-time |
| 101 | +``` |
| 102 | +</TabItem> |
| 103 | +<TabItem label="yarn"> |
| 104 | +```bash |
| 105 | +yarn add date-and-time |
| 106 | +``` |
| 107 | +</TabItem> |
| 108 | +<TabItem label="pnpm"> |
| 109 | +```bash |
| 110 | +pnpm add date-and-time |
| 111 | +``` |
| 112 | +</TabItem> |
| 113 | +</Tabs> |
| 114 | + |
| 115 | +## Community |
| 116 | + |
| 117 | +- [GitHub Repository](https://github.com/knowledgecode/date-and-time) |
| 118 | +- [npm Package](https://www.npmjs.com/package/date-and-time) |
| 119 | +- [Issue Tracker](https://github.com/knowledgecode/date-and-time/issues) |
0 commit comments