{"_id":"@expo/timeago.js","_rev":"49-b230d42cffe8bddd98faa1847532b47d","name":"@expo/timeago.js","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@expo/timeago.js","version":"1.0.0","keywords":["timeago","datetime","*** time ago","date","javascript timeago"],"author":{"url":"https://timeago.org","name":"hustcc"},"license":"MIT","_id":"@expo/timeago.js@1.0.0","maintainers":[{"name":"fiber-god","email":"datwheat@gmail.com"},{"name":"ide","email":"ide+npm@jameside.com"},{"name":"brentvatne","email":"brentvatne@gmail.com"},{"name":"ccheever","email":"ccheever@gmail.com"},{"name":"evanbacon","email":"baconbrix@gmail.com"},{"name":"quinlanj","email":"quinlanjung@gmail.com"},{"name":"esamelson","email":"eric@expo.io"},{"name":"fson","email":"ville.immonen@iki.fi"},{"name":"expoadmin","email":"support@expo.io"},{"name":"charliecruzan","email":"charliecruzan@gmail.com"},{"name":"tsapeta","email":"npm@tsapeta.com"},{"name":"dsokal","email":"dominiksokal@gmail.com"},{"name":"tcdavis","email":"tc@expo.io"},{"name":"exponent","email":"exponent.team@gmail.com"},{"name":"wschurman","email":"wschurman@gmail.com"},{"name":"bbarthec","email":"bartlomiejbukowski.b@gmail.com"},{"name":"jkhales","email":"jonathan@expo.io"},{"name":"wkozyra","email":"wojciech.kozyra@swmansion.com"},{"name":"bycedric","email":"me@bycedric.com"},{"name":"lukmccall","email":"kosmatylukasz@gmail.com"},{"name":"jonsamp","email":"sampjon@gmail.com"},{"name":"princefleaswallow","email":"mhampton@hey.com"},{"name":"andyboythekid","email":"andydevs123@gmail.com"},{"name":"kudochien","email":"ckchien@gmail.com"},{"name":"haydendaly","email":"haydencdaly@gmail.com"}],"homepage":"https://github.com/expo/timeago.js#readme","bugs":{"url":"https://github.com/expo/timeago.js/issues"},"dist":{"shasum":"8fb2b17e93e7a8d28387a4d292af12e071040045","tarball":"https://registry.npmjs.org/@expo/timeago.js/-/timeago.js-1.0.0.tgz","fileCount":36,"integrity":"sha512-PD45CGlCL8kG0U3YcH1NvYxQThw5XAS7qE9bgP4L7dakm8lsMz+p8BQ1IjBFMmImawVWsV3py6JZINaEebXLnw==","signatures":[{"sig":"MEQCICdeyPE9e/6yg1qMe717Sxaf6Zl+2GikkAhZJjUCmYw8AiA7yza5OSxCyVGlHPHS5Hl2Thi9PW+JpBbm9MQ+LDy4DQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32476,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2GhyCRA9TVsSAnZWagAAMRYQAJXs3APCOculUEnBpIzi\nnvv1C/QZYiz/KuheREZZ5rK3s9AKStowNECEuCmAnRBY8DyHYbB+G/3h6QZ+\n+8AhMA4WOiJqv2MPW7+KY8c9dkMNPcN/ZTaFKqf6Vg7QqnDnxNGpKHa+p1cJ\nZ4KdLmRctBULARkLsUFIPWPF3KxbeAhWygugWaEP6uYIBRCWgOIaIrpzW7ik\nGZPW4FvR+Jew6ivamtowQ1ALpm7tXK4w6IxhTWjlR1+UlYq8YFvxYIm7tMe3\nmyI+SlV3fkWvY69m2DYzU7v1EL1x6HqgwmP9dpPA3lBnKdN4dcarVxKLZnZW\nhPWk+cetebmmUQm+dEIWIKZL759GPnCZhtpvEGFgdOXt64XaXlGSXycgT+g/\ngaOnQa62u1hUTlIQONNzmUqxAQDsQOAEKtvkN7YVqYh2mv+WBu6dePtxwrz5\nnj3eYtpJDizjBVctTT5KCkOlUiI1FxUPH2vkunO7reIIEuGxDThhY+UphnUU\nmc6AdDbmmQIQYsM6kGVDMZwyniKcXRsZ8b/kWkBjhlUPQm3EAPWC5vwRe0Uy\nktMGEQ9X/YzlWpC65JZe5Di8SDT5gNP5mGUm6INvbfAUAzSKU0ZxPb7s5l/Q\nruXztCHNKK9IS8AG+jUc2iZAyu/e9OME8hkA2vJHQwltfMNzx1w0CIyrg6l1\nVNTz\r\n=ek1v\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"preset":"ts-jest","runner":"jest-electron/runner","testURL":"https://timeago.org","testRegex":"(/__tests__/.*(test|spec))\\.ts$","collectCoverage":true,"testEnvironment":"jest-electron/environment","setupFilesAfterEnv":["jest-expect"],"collectCoverageFrom":["src/**/*.ts","!**/node_modules/**"]},"main":"lib/index.js","husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS","pre-commit":"npm run lint-staged"}},"gitHead":"fd37c1aa2f30243e464fd99e776389ae1bfacafe","scripts":{"ci":"npm run lint && npm run test && npm run size && lint-md .","lint":"eslint src/**/* __tests__/**/*","size":"limit-size","test":"jest","build":"npm run build:cjs && npm run build:umd","build:cjs":"rimraf ./lib && tsc --module commonjs --outDir lib","build:esm":"rimraf ./esm && tsc --module ESNext --outDir esm","build:umd":"rimraf ./dist && rollup -c && cp -rf dist/ gh-pages && npm run size","lint-staged":"lint-staged","prepublishOnly":"npm run build"},"summary":"timeago.js is a simple library (less than 1kb) to used to format datetime with `*** time ago` statement. eg: '3 hours ago'.","_npmUser":{"name":"dsokal","email":"dominiksokal@gmail.com"},"limit-size":[{"gzip":true,"path":"dist/timeago.min.js","limit":"1.1 Kb"},{"gzip":true,"path":"dist/timeago.full.min.js","limit":"10 Kb"}],"repository":{"url":"git+https://github.com/expo/timeago.js.git","type":"git"},"_npmVersion":"7.10.0","description":"timeago.js is a simple library (only 1kb) to used to format datetime with `*** time ago` statement. eg: '3 hours ago'. localization supported.","directories":{},"lint-staged":{"*.{ts,tsx}":["eslint --fix","prettier --write","git add"]},"_nodeVersion":"16.0.0","dependencies":{},"officialName":"timeago.js","_hasShrinkwrap":false,"devDependencies":{"jest":"^24.9.0","husky":"^3.0.5","eslint":"^6.4.0","rimraf":"^3.0.0","rollup":"^1.23.1","ts-jest":"^24.1.0","prettier":"^1.18.2","cross-env":"^5.1.3","limit-size":"^0.1.2","typescript":"^3.6.3","@types/jest":"^24.0.18","jest-expect":"^0.0.1","lint-md-cli":"^0.1.0","lint-staged":"^9.3.0","jest-electron":"^0.1.7","jest-date-mock":"^1.0.5","@commitlint/cli":"^8.2.0","rollup-plugin-uglify":"^6.0.3","eslint-config-prettier":"^6.3.0","rollup-plugin-typescript":"^1.0.1","@typescript-eslint/parser":"^2.3.1","rollup-plugin-node-resolve":"^5.2.0","@typescript-eslint/eslint-plugin":"^2.3.1"},"_npmOperationalInternal":{"tmp":"tmp/timeago.js_1.0.0_1631536725268_0.6116625904439976","host":"s3://npm-registry-packages"}}},"time":{"created":"2021-09-13T12:38:45.215Z","modified":"2026-09-23T11:27:17.675Z","1.0.0":"2021-09-13T12:38:45.410Z"},"bugs":{"url":"https://github.com/expo/timeago.js/issues"},"author":{"url":"https://timeago.org","name":"hustcc"},"license":"MIT","homepage":"https://github.com/expo/timeago.js#readme","keywords":["timeago","datetime","*** time ago","date","javascript timeago"],"repository":{"url":"git+https://github.com/expo/timeago.js.git","type":"git"},"description":"timeago.js is a simple library (only 1kb) to used to format datetime with `*** time ago` statement. eg: '3 hours ago'. localization supported.","maintainers":[{"email":"ide+npm@jameside.com","name":"ide"},{"email":"brentvatne@gmail.com","name":"brentvatne"},{"email":"support@expo.io","name":"expoadmin"},{"email":"exponent.team@gmail.com","name":"exponent"},{"email":"me@bycedric.com","name":"bycedric"},{"email":"ckchien@gmail.com","name":"kudochien"},{"email":"hughesno1@gmail.com","name":"alanhughes"},{"email":"npm@tsapeta.com","name":"tsapeta"},{"email":"brent+expobotnpm@expo.io","name":"expo-bot"},{"email":"phil@kitten.sh","name":"philpl"},{"email":"ccheever@gmail.com","name":"ccheever"},{"email":"sz.dziedz@gmail.com","name":"szdziedzic"},{"email":"wschurman@gmail.com","name":"wschurman"}],"readme":"# timeago.js\n\n> **timeago.js** is a nano library(less than `2 kb`)  used to format datetime with `*** time ago` statement. eg: '3 hours ago'.\n\n - i18n supported.\n - Time `ago` and time `in` supported.\n - Real-time render supported.\n - Node and browser supported.\n - Well tested.\n\n[Official website](https://timeago.org/). React version here: [timeago-react](https://github.com/hustcc/timeago-react). Python version here: [timeago](https://github.com/hustcc/timeago).\n\n[![npm Version](https://img.shields.io/npm/v/timeago.js.svg)](https://www.npmjs.com/package/timeago.js)\n[![unpkg](https://img.shields.io/npm/v/timeago.js?label=cdn)](https://unpkg.com/browse/timeago.js/)\n[![Build Status](https://github.com/hustcc/timeago.js/workflows/build/badge.svg)](https://github.com/hustcc/timeago.js/actions)\n[![Coverage Status](https://coveralls.io/repos/github/hustcc/timeago.js/badge.svg?branch=master)](https://coveralls.io/github/hustcc/timeago.js?branch=master)\n[![Dist gzip](https://img.badgesize.io/https://unpkg.com/timeago.js/dist/timeago.min.js?compression=gzip)](https://unpkg.com/timeago.js/dist/timeago.min.js)\n[![npm Download](https://img.shields.io/npm/dm/timeago.js.svg)](https://www.npmjs.com/package/timeago.js)\n[![npm License](https://img.shields.io/npm/l/timeago.js.svg)](https://www.npmjs.com/package/timeago.js)\n\n\nSuch as\n\n```plain\njust now\n12 seconds ago\n2 hours ago\n3 days ago\n3 weeks ago\n2 years ago\n\nin 12 seconds\nin 3 minutes\nin 24 days\nin 6 months\n```\n\n\n## Usage\n\n - install\n\n```bash\nnpm install timeago.js\n```\n\n - import\n\n```ts\nimport { format, render, cancel, register } from 'timeago.js';\n```\n\nor import with `script` tag in html file and access global variable `timeago`.\n\n```html\n<script src=\"dist/timeago.min.js\"></script>\n```\n\n - example\n\n```ts\n// format the time with locale\nformat('2016-06-12', 'en_US');\n```\n\n## CDN \n\nAlternatively to NPM, you can also use a CDN which will reflect the latest version as soon as it is published to npm.\n\n```html\n<script src=\"//unpkg.com/timeago.js\"></script>\n```\n\n## API\n\nThere only 4 API below.\n\n - **format**\n\n> `format(date[, locale = 'en_US', opts])`, format a Date instance / timestamp / date string to string.\n\n```ts\nimport { format } from 'timeago.js';\n\n// format timestamp\nformat(1544666010224);\n\n// format date instance\nformat(new Date(1544666010224));\n\n// format date string\nformat('2018-12-12');\n\n// format with locale\nformat(1544666010224, 'zh_CN');\n\n// format with locale and relative date\nformat(1544666010224, 'zh_CN', { relativeDate: '2018-11-11' });\n\n// e.g.\nformat(Date.now() - 11 * 1000 * 60 * 60); // returns '11 hours ago'\n``` \n\nThe default locale is `en_US`, and the library contains `en_US` and `zh_CN` build-in.\n\n - **render** & **cancel**\n   \n> `render(dom[, locale = 'en_US', opts])`  \n> `cancel([dom])`\n\n> Make a dom with `datetime` attribute automatic rendering and cancel.\n\nHTML code:\n\n```html\n<div class=\"timeago\" datetime=\"2016-06-30 09:20:00\"></div>\n```\n\nJavascript code:\n\n```ts\nimport { render, cancel } from 'timeago.js';\n\nconst nodes = document.querySelectorAll('.timeago');\n\n// use render method to render nodes in real time\nrender(nodes, 'zh_CN');\n\n// render with opts\n// render(nodes, 'en_US', { minInterval: 3 });\n\n// cancel all real-time render task\ncancel();\n\n// or cancel for the specific one\ncancel(nodes[0])\n```\n\nThe 3rd parameter `opts` contains:\n\n```ts\nexport type Opts = {\n  /** the relative date */\n  readonly relativeDate?: TDate;\n  /** the realtime min update interval */\n  readonly minInterval?: number;\n};\n``` \n\n> The DOM object should have the attribute `datetime` with date formatted string.\n\n - **register**\n\n> `register(locale, localeFunc)`, register a new locale, build-in locale contains: `en_US`, `zh_CN`, [all locales here](src/lang).\n\nYou can register your own language with `register` API.\n\n```ts\nconst localeFunc = (number: number, index: number, totalSec: number): [string, string] => {\n  // number: the timeago / timein number;\n  // index: the index of array below;\n  // totalSec: total seconds between date to be formatted and today's date;\n  return [\n    ['just now', 'right now'],\n    ['%s seconds ago', 'in %s seconds'],\n    ['1 minute ago', 'in 1 minute'],\n    ['%s minutes ago', 'in %s minutes'],\n    ['1 hour ago', 'in 1 hour'],\n    ['%s hours ago', 'in %s hours'],\n    ['1 day ago', 'in 1 day'],\n    ['%s days ago', 'in %s days'],\n    ['1 week ago', 'in 1 week'],\n    ['%s weeks ago', 'in %s weeks'],\n    ['1 month ago', 'in 1 month'],\n    ['%s months ago', 'in %s months'],\n    ['1 year ago', 'in 1 year'],\n    ['%s years ago', 'in %s years']\n  ][index];\n};\n// register your locale with timeago\nregister('my-locale', localeFunc);\n\n// use it\nformat('2016-06-12', 'my-locale');\n```\n\n\n## Contributions\n\n1. The website is based on [rmm5t/jquery-timeago](https://github.com/rmm5t/jquery-timeago) which is a nice and featured project but it depends on jQuery.\n2. **locale translations**: The library needs more locale translations. You can:\n\n - Open an issue to write the locale translations, or submit a pull request. How to ? see [locales translation](src/lang/).\n - Please **test** the locale by exec `npm test`. How to write test cases, see [locales test cases](__tests__/lang/).\n\n\n## LICENSE\n\nMIT@[hustcc](https://github.com/hustcc)\n","readmeFilename":"README.md"}