{"_id":"@dongxiang678/dtejs","_rev":"4-f9230293a65acd68ea75f1f63888e261","name":"@dongxiang678/dtejs","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@dongxiang678/dtejs","version":"1.0.0","keywords":["date","utils","typescript","lightweight","i18n"],"author":{"name":"董翔","email":"3631247406@qq.com"},"license":"MIT","_id":"@dongxiang678/dtejs@1.0.0","maintainers":[{"name":"dongxiang678","email":"3631247406@qq.com"}],"homepage":"https://github.com/dxiangwiki/dtejs#readme","bugs":{"url":"https://github.com/dxiangwiki/dtejs/issues"},"dist":{"shasum":"ff76b69739d29d7553cae78a2ddeae3c0a2598ec","tarball":"https://registry.npmjs.org/@dongxiang678/dtejs/-/dtejs-1.0.0.tgz","fileCount":6,"integrity":"sha512-yco8ioiS9ZiXpss/MPoM+TcyhGO2E5erjiiwwi1TDldC1xeziKxj3kx2wKeR0xT3LBto/yhvc69vl9+5j0AiQg==","signatures":[{"sig":"MEUCIQD1vjtA0RP7kInZl4aEnjTyMMn0cIRi7c0Ftnc+hirIQgIgVq5z/e84Pdv0ZzrM5uo+4zn12FOauclT1gY/Xf4aFS0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19796},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=14.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"scripts":{"test":"vitest run","build":"tsc","test:ui":"vitest ui","prepublishOnly":"npm run test && npm run build"},"_npmUser":{"name":"dongxiang678","email":"3631247406@qq.com"},"repository":{"url":"git+https://github.com/dxiangwiki/dtejs.git","type":"git"},"_npmVersion":"11.4.2","description":"超轻量 TS 原生日期工具库，支持国际化、相对时间、日期比较","directories":{},"_nodeVersion":"22.15.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.0","@vitest/ui":"^4.1.0"},"_npmOperationalInternal":{"tmp":"tmp/dtejs_1.0.0_1774055542241_0.9565757164509423","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@dongxiang678/dtejs","version":"1.0.1","keywords":["date","utils","typescript","lightweight","i18n"],"author":{"name":"董翔","email":"3631247406@qq.com"},"license":"MIT","_id":"@dongxiang678/dtejs@1.0.1","maintainers":[{"name":"dongxiang678","email":"3631247406@qq.com"}],"homepage":"https://github.com/dxiangwiki/dtejs#readme","bugs":{"url":"https://github.com/dxiangwiki/dtejs/issues"},"dist":{"shasum":"5d93892234c4dcfe4570ff68cdf38447be5872fc","tarball":"https://registry.npmjs.org/@dongxiang678/dtejs/-/dtejs-1.0.1.tgz","fileCount":6,"integrity":"sha512-PQLI2BPp+xubI31eYm/vF3FkpKIAgvBYlrYe9NF3/lu2x+1Wh4mU7kEWTOq0lcDbwn7fIm6nhzxceOEKCm1SbQ==","signatures":[{"sig":"MEYCIQDSJ2MTC5xumMMffc58fhA7EnVT+ckMDhXNzrmjqZEJ6gIhAOW52VD3RFhLlmvX5NXkmTgQKgO6aYEjNk9WtDkCeyNt","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17516},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=14.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"scripts":{"test":"vitest run","build":"tsc","test:ui":"vitest ui","prepublishOnly":"npm run test && npm run build"},"_npmUser":{"name":"dongxiang678","email":"3631247406@qq.com"},"repository":{"url":"git+https://github.com/dxiangwiki/dtejs.git","type":"git"},"_npmVersion":"11.4.2","description":"超轻量 TS 原生日期工具库，支持国际化、相对时间、日期比较","directories":{},"_nodeVersion":"22.15.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.0","@vitest/ui":"^4.1.0"},"_npmOperationalInternal":{"tmp":"tmp/dtejs_1.0.1_1774082177716_0.3457517033398927","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@dongxiang678/dtejs","version":"1.0.2","keywords":["date","utils","typescript","lightweight","i18n"],"author":{"name":"董翔","email":"3631247406@qq.com"},"license":"MIT","_id":"@dongxiang678/dtejs@1.0.2","maintainers":[{"name":"dongxiang678","email":"3631247406@qq.com"}],"homepage":"https://github.com/dxiangwiki/dtejs#readme","bugs":{"url":"https://github.com/dxiangwiki/dtejs/issues"},"dist":{"shasum":"2a7edfebe7bfa4bd9ac0ada70dca79394258a5ac","tarball":"https://registry.npmjs.org/@dongxiang678/dtejs/-/dtejs-1.0.2.tgz","fileCount":6,"integrity":"sha512-vFx6Kjhz2K8M1Rca7/t7olaa+ByTrNvH4W/lR6u4RuYlO8/c8wquwYvLXq+/LSKVGGMrurkJG2Jonu3rAj1sJw==","signatures":[{"sig":"MEQCIHieDH+BEKOUjnQuWffacVsP+Jdc78BljL0K6MHpFNohAiAFhL9/d23QoX8Sfe5EmNzlROZGgRf6LxxLn7U25yWcuQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17715},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=14.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"3681a0afe114e4b4da324ea96d949a67ed08149f","scripts":{"test":"vitest run","build":"tsc","test:ui":"vitest ui","prepublishOnly":"npm run test && npm run build"},"_npmUser":{"name":"dongxiang678","email":"3631247406@qq.com"},"repository":{"url":"git+https://github.com/dxiangwiki/dtejs.git","type":"git"},"_npmVersion":"11.4.2","description":"超轻量 TS 原生日期工具库，支持国际化、相对时间、日期比较","directories":{},"_nodeVersion":"22.15.0","_hasShrinkwrap":false,"devDependencies":{"rollup":"^2.80.0","vitest":"^4.1.0","@vitest/ui":"^4.1.0","@rollup/plugin-terser":"^1.0.0","@rollup/plugin-commonjs":"^29.0.2","@rollup/plugin-typescript":"^12.3.0","@rollup/plugin-node-resolve":"^16.0.3"},"_npmOperationalInternal":{"tmp":"tmp/dtejs_1.0.2_1774089080699_0.9576369628322383","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@dongxiang678/dtejs","version":"1.0.3","description":"超轻量 TS 原生日期工具库，支持国际化、相对时间、日期比较","main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.js","unpkg":"dist/dtejs.umd.js","jsdelivr":"dist/dtejs.umd.js","exports":{".":{"import":"./dist/index.js","require":"./dist/index.js","browser":"./dist/dtejs.umd.js","types":"./dist/index.d.ts"}},"keywords":["date","utils","typescript","lightweight","i18n"],"author":{"name":"董翔","email":"3631247406@qq.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/dxiangwiki/dtejs.git"},"bugs":{"url":"https://github.com/dxiangwiki/dtejs/issues"},"homepage":"https://github.com/dxiangwiki/dtejs#readme","scripts":{"build":"tsc","build:umd":"npx esbuild dist/index.js --format=iife --global-name=dtejs --outfile=dist/dtejs.umd.js --minify","test":"vitest run","test:ui":"vitest ui","prepublishOnly":"npm run test && npm run build && npm run build:umd"},"engines":{"node":">=14.0.0"},"devDependencies":{"@rollup/plugin-commonjs":"^29.0.2","@rollup/plugin-node-resolve":"^16.0.3","@rollup/plugin-terser":"^1.0.0","@rollup/plugin-typescript":"^12.3.0","@vitest/ui":"^4.1.0","esbuild":"^0.27.4","rollup":"^2.80.0","tslib":"^2.8.1","vitest":"^4.1.0"},"type":"module","_id":"@dongxiang678/dtejs@1.0.3","gitHead":"d770e3d08e795cda0e46d23c6eb2c889386905d9","_nodeVersion":"22.15.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-hjhKFMR/Szs0+VjBZH5+OFI6J9xd1niQKnZiZf0ZkTveWkruOm4EkfeeyNZ4siSq8RmeOfZKQJmc0JoE4UYqJQ==","shasum":"9b8cfb6bdc924e383963e439cb1252474d88db1b","tarball":"https://registry.npmjs.org/@dongxiang678/dtejs/-/dtejs-1.0.3.tgz","fileCount":7,"unpackedSize":20430,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIESN6356C1WONCdTzdUQF2NqcYm+Dqbe2tl+CC5W9TklAiAgzC2t9r+uXP/f1cDk1Xx/aQahLv8RY6QcRUcblfewuA=="}]},"_npmUser":{"name":"dongxiang678","email":"3631247406@qq.com"},"directories":{},"maintainers":[{"name":"dongxiang678","email":"3631247406@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dtejs_1.0.3_1774090679356_0.6354581892120936"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-21T01:12:22.167Z","modified":"2026-03-21T10:57:59.649Z","1.0.0":"2026-03-21T01:12:22.421Z","1.0.1":"2026-03-21T08:36:17.859Z","1.0.2":"2026-03-21T10:31:20.862Z","1.0.3":"2026-03-21T10:57:59.503Z"},"bugs":{"url":"https://github.com/dxiangwiki/dtejs/issues"},"author":{"name":"董翔","email":"3631247406@qq.com"},"license":"MIT","homepage":"https://github.com/dxiangwiki/dtejs#readme","keywords":["date","utils","typescript","lightweight","i18n"],"repository":{"type":"git","url":"git+https://github.com/dxiangwiki/dtejs.git"},"description":"超轻量 TS 原生日期工具库，支持国际化、相对时间、日期比较","maintainers":[{"name":"dongxiang678","email":"3631247406@qq.com"}],"readme":"# dtejs\r\n\r\n超轻量（<2kB）JS 原生日期时间工具库，零依赖、支持国际化、API 极简易用。\r\n\r\n[![npm version](https://img.shields.io/npm/v/@dongxiang678/dtejs.svg)](https://www.npmjs.com/package/@dongxiang678/dtejs)\r\n\r\n## ✨ 特性  \r\n\r\n- 🚀 **超轻量**：压缩后小于 2kB，零任何依赖\r\n- 👨‍💻 **TypeScript 原生**：完整类型定义，IDE 智能提示\r\n- 🌍 **国际化支持**：内置中文/英文，易扩展多语言\r\n- ⏳ **智能相对时间**：自动识别过去/未来（5分钟前、2天后）\r\n- 📦 **优雅链式调用**：简洁流畅的 API 设计\r\n- 🛡️ **完善边界容错**：兼容各类异常日期格式\r\n\r\n## 📦 安装\r\n\r\n```bash\r\nnpm install dtelib\r\n# 或\r\nyarn add dtelib\r\n# 或\r\npnpm add dtelib\r\n```\r\n\r\n## 🚀 快速上手\r\n\r\n```typescript\r\nimport { Dte, format, fromNow } from 'dtelib';\r\n\r\n// 基础日期格式化\r\nformat('2026-03-20', 'YYYY-MM-DD'); // '2026-03-20'\r\nformat('2026-03-20', 'YYYY年MM月DD日'); // '2026年03月20日'\r\n\r\n// 智能相对时间（自动判断过去/未来）\r\nfromNow(Date.now() - 5 * 60 * 1000); // '5分钟前'\r\nfromNow(Date.now() + 3 * 24 * 3600 * 1000, 'en-US'); // '3 days later'\r\n\r\n// 链式日期计算\r\nconst tomorrow = new Dte('2026-03-20')\r\n  .add(1, 'day')\r\n  .format('YYYY-MM-DD'); // '2026-03-21'\r\n\r\n// 日期大小对比\r\nDte.compare('2026-03-20', '2026-03-19'); // 1（大于）\r\nDte.compare('2026-03-20', '2026-03-20'); // 0（相等）\r\n```\r\n\r\n## 📖 API 文档\r\n\r\n### 类：`Dte`\r\n\r\n#### 构造函数\r\n```typescript\r\nnew Dte(date?: Date | number | string, locale?: 'zh-CN' | 'en-US')\r\n```\r\n| 参数   | 类型                     | 默认值   | 说明                       |\r\n| ------ | ------------------------ | -------- | -------------------------- |\r\n| date   | Date \\| number \\| string | 当前时间 | 日期对象/时间戳/日期字符串 |\r\n| locale | zh-CN \\| en-US           | zh-CN    | 语言环境                   |\r\n\r\n#### 实例方法\r\n- **format(template)**：格式化日期  \r\n  支持模板：`YYYY-MM-DD` / `YYYY-MM-DD HH:mm:ss` / `YYYY年MM月DD日` 等\r\n- **fromNow()**：获取相对当前时间文案\r\n- **add(amount, unit)**：日期增量（秒/分/时/天，返回新实例）\r\n- **timestamp(type)**：获取时间戳（默认毫秒，可选秒）\r\n\r\n#### 静态方法\r\n- **Dte.compare(date1, date2)**：对比两日期，返回 1/-1/0\r\n\r\n### 快捷工具函数\r\n- `format(date, template, locale?)`：无需实例，快速格式化\r\n- `fromNow(date, locale?)`：无需实例，快速获取相对时间\r\n\r\n## 🌍 国际化\r\n内置 2 种语言，默认中文\r\n```typescript\r\n// 实例切换英文\r\nnew Dte(Date.now() - 3600000, 'en-US').fromNow(); // 1 hour ago\r\n\r\n// 函数切换英文\r\nfromNow(Date.now() + 86400000, 'en-US'); // 1 day later\r\n```\r\n\r\n## 📊 竞品对比\r\n| 特性       | dtelib   | dayjs    | moment       |\r\n| ---------- | -------- | -------- | ------------ |\r\n| 体积       | <2kB     | ~2kB     | ~200kB       |\r\n| TypeScript | 原生支持 | 需适配   | 需额外类型包 |\r\n| 依赖       | 零依赖   | 零依赖   | 冗余依赖     |\r\n| 维护状态   | 持续活跃 | 持续活跃 | 已停止维护   |\r\n\r\n## 📄 许可证\r\nMIT © dtelib\r\n\r\n## 🔗 相关链接\r\n- [GitHub 仓库](https://github.com/dxiangwiki/dtelib)\r\n- [问题反馈](https://github.com/dxiangwiki/dtelib/issues)","readmeFilename":"README.md"}