{"name":"tiny-relative-date","version":"2.0.1","author":{"url":"https://wildlyinaccurate.com/","name":"Joseph Wynn","email":"joseph@wildlyinaccurate.com"},"license":"MIT","_id":"tiny-relative-date@2.0.1","maintainers":[{"name":"wildlyinaccurate","email":"joseph@wildlyinaccurate.com"}],"homepage":"https://github.com/wildlyinaccurate/relative-date#readme","bugs":{"url":"https://github.com/wildlyinaccurate/relative-date/issues"},"dist":{"shasum":"2832c49cca70580d06c15312f55d315eff7263ee","tarball":"http://registry-npm.ywwl.com/tiny-relative-date/download/tiny-relative-date-2.0.1.tgz","fileCount":18,"integrity":"sha512-FHu+pqmlca53V+4iFiuUKwV19EdTGdrTPb1K+xJToDlj0DCT2VMjJtKiRtdSCv9N3prKcc1aAyaVXJYh9xolrQ==","signatures":[{"sig":"MEUCIQCe33lZcAqqLkABg1Tj33dhlA7M7KFQh8sDOhKX6g36+gIgS0nIhd6+JuYDQAadN6X/3iXhq39N3WVqTUg9dGHVcs8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22768,"size":6073,"noattachment":false,"key":"/tiny-relative-date/-/tiny-relative-date-2.0.1.tgz"},"main":"lib/index.js","types":"./lib/index.d.ts","module":"src/index.js","gitHead":"f53ffe3042d6552288cc973d5797cfde92551338","scripts":{"test":"npm run eslint && npm run jasmine","build":"babel src -d lib && cp src/*.d.ts lib/","eslint":"eslint --fix src/**/*.js spec/*.js","jasmine":"TZ=UTC jasmine","prepublish":"npm run build"},"_npmUser":{"name":"wildlyinaccurate","email":"joseph@wildlyinaccurate.com"},"repository":{"url":"git+https://github.com/wildlyinaccurate/relative-date.git","type":"git"},"_npmVersion":"11.3.0","description":"Tiny function that provides relative, human-readable dates.","directories":{},"_nodeVersion":"24.2.0","_hasShrinkwrap":false,"devDependencies":{"eslint":"^4.19.1","jasmine":"^3.1.0","babel-cli":"^6.26.0","babel-register":"^6.26.0","eslint-plugin-node":"^6.0.1","babel-preset-es2015":"^6.24.1","eslint-plugin-import":"^2.11.0","eslint-plugin-promise":"^3.7.0","jasmine-spec-reporter":"^4.2.1","eslint-config-standard":"^11.0.0","eslint-plugin-standard":"^3.0.1","babel-plugin-add-module-exports":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/tiny-relative-date_2.0.1_1750128967893_0.23422995873075902","host":"s3://npm-registry-packages-npm-production"},"readme":"<h1><sup><small>(Tiny)</small></sup> Relative Date</h1>\n\nTiny function that provides relative, localised, human-readable dates.\n\n![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/tiny-relative-date.svg?style=for-the-badge)\n![Monthly Downloads](https://img.shields.io/npm/dm/tiny-relative-date.svg?style=for-the-badge)\n![Build Status](https://img.shields.io/travis/wildlyinaccurate/tiny-relative-date.svg?style=for-the-badge)\n\n## Installation\n\n```\nnpm install tiny-relative-date\n```\n\n## Usage\n\nThe module returns a `relativeDate` function with English translations by default.\n\n```js\nconst relativeDate = require('tiny-relative-date')\n```\n\nThe `relativeDate` function accepts date strings or `Date` objects.\n\n```js\nrelativeDate('2017-06-25 09:00') // '12 hours ago'\nrelativeDate(new Date()) // 'just now'\n```\n\nThe value of \"now\" can also be passed as a second parameter.\n\n```js\nconst now = new Date('2017-06-25 08:00:00')\nconst date = new Date('2017-06-25 07:00:00')\n\nrelativeDate(date, now) // 'an hour ago'\n```\n\n### Using a non-English locale\n\nThe tiny-relative-date module can be initialised with a locale. See the [translations directory](./translations) for a list of available locales.\n\n```js\nconst relativeDateFactory = require('tiny-relative-date/lib/factory')\nconst deTranslations = require('tiny-relative-date/translations/de')\nconst relativeDate = relativeDateFactory(deTranslations)\n\nrelativeDate(new Date()) // 'gerade eben'\n```\n\n### Using a custom locale\n\nYou can also use a completely custom locale by passing a translations object instead of a locale string. Translations can be plain strings with a `{{time}}` placeholder, or they can be functions. See the **Adding new locales** section below for a list of translation keys.\n\n```js\nconst relativeDateFactory = require('tiny-relative-date/lib/factory')\nconst relativeDate = relativeDateFactory({\n  hoursAgo: '{{time}}h ago',\n  daysAgo: (days) => `${days * 24}h ago`\n})\n\nrelativeDate('2017-06-25 07:00:00') // '2h ago'\nrelativeDate('2017-06-24 06:00:00') // '27h ago'\n```\n\n## Contributing\n\nContributions are welcome! Running this project locally requires Git and Node.js.\n\n```\ngit clone git@github.com:wildlyinaccurate/tiny-relative-date.git\ncd tiny-relative-date/\nnpm install\n```\n\nOnce you are set up, you can make changes to files in the `src/`, `spec/` and `translations/` directories. Build any changes you make by running\n\n```\nnpm run build\n```\n\nAnd run the tests with\n\n```\nnpm run test\n```\n\n### Adding new locales\n\nIf you would like to add a new locale, please create a JSON file in the `translations` directory and ensure it has the following keys:\n\n| Key                    | Default value (\"en\" locale) |\n|------------------------|-----------------------------|\n| `justNow`             | just now                    |\n| `secondsAgo`          | {{time}} seconds ago        |\n| `aMinuteAgo`         | a minute ago                |\n| `minutesAgo`          | {{time}} minutes ago        |\n| `anHourAgo`          | an hour ago                 |\n| `hoursAgo`            | {{time}} hours ago          |\n| `aDayAgo`            | yesterday                   |\n| `daysAgo`             | {{time}} days ago           |\n| `aWeekAgo`           | a week ago                  |\n| `weeksAgo`            | {{time}} weeks ago          |\n| `aMonthAgo`          | a month ago                 |\n| `monthsAgo`           | {{time}} months ago         |\n| `aYearAgo`           | a year ago                  |\n| `yearsAgo`            | {{time}} years ago          |\n| `overAYearAgo`      | over a year ago             |\n| `secondsFromNow`     | {{time}} seconds from now   |\n| `aMinuteFromNow`    | a minute from now           |\n| `minutesFromNow`     | {{time}} minutes from now   |\n| `anHourFromNow`     | an hour from now            |\n| `hoursFromNow`       | {{time}} hours from now     |\n| `aDayFromNow`       | tomorrow                    |\n| `daysFromNow`        | {{time}} days from now      |\n| `aWeekFromNow`      | a week from now             |\n| `weeksFromNow`       | {{time}} weeks from now     |\n| `aMonthFromNow`     | a month from now            |\n| `monthsFromNow`      | {{time}} months from now    |\n| `aYearFromNow`      | a year from now             |\n| `yearsFromNow`       | {{time}} years from now     |\n| `overAYearFromNow` | over a year from now        |\n","publish_time":1750128968062,"_cnpm_publish_time":1750128968062,"dist-tags":{"latest":"2.0.2"}}