├── .babelrc ├── .gitattributes ├── .gitignore ├── .npmignore ├── .nycrc ├── .travis.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── MIGRATION.md ├── README.md ├── bin ├── create-commonjs-package-json.js ├── generate-load-all-locales.js └── generate-locale-messages.js ├── cache ├── index.cjs ├── index.cjs.js ├── index.js └── package.json ├── gradation ├── README.md ├── index.cjs ├── index.cjs.js ├── index.js └── package.json ├── index.cjs ├── index.cjs.js ├── index.d.ts ├── index.js ├── load-all-locales ├── index.cjs ├── index.cjs.js ├── index.js └── package.json ├── locale-more-styles ├── README.md ├── ckb │ ├── long-time.json │ ├── mini.json │ ├── now.json │ └── short-time.json ├── da │ ├── long-time.json │ ├── mini.json │ └── now.json ├── de │ ├── long-time.json │ ├── mini.json │ └── now.json ├── el │ ├── mini.json │ └── now.json ├── en │ ├── long-time.json │ ├── mini.json │ ├── now.json │ └── short-time.json ├── eo │ ├── long-time.json │ ├── mini.json │ ├── now.json │ └── short-time.json ├── es │ ├── long-time.json │ ├── mini.json │ └── now.json ├── fr │ ├── long-time.json │ ├── mini.json │ └── now.json ├── hi │ ├── mini.json │ └── now.json ├── id │ ├── long-time.json │ ├── mini.json │ ├── now.json │ └── short-time.json ├── it │ ├── long-time.json │ ├── mini.json │ └── now.json ├── ko │ ├── mini.json │ └── now.json ├── nl │ ├── long-time.json │ ├── mini.json │ └── now.json ├── pl │ ├── long-time.json │ ├── mini.json │ ├── now.json │ └── short-time.json ├── pt │ ├── long-time.json │ ├── mini.json │ └── now.json ├── ro │ ├── long-time.json │ ├── mini.json │ └── now.json ├── ru │ ├── long-time.json │ ├── mini.json │ ├── now.json │ └── short-time.json ├── sv │ ├── long-time.json │ ├── mini.json │ └── now.json └── zh │ ├── mini.json │ └── now.json ├── package-lock.json ├── package.json ├── project.sublime-project ├── prop-types ├── index.cjs ├── index.cjs.js ├── index.js └── package.json ├── rollup.config.mjs ├── source ├── LocaleDataStore.js ├── PropTypes.js ├── TimeAgo.js ├── TimeAgo.test.js ├── cache.js ├── cache.test.js ├── isStyleObject.js ├── isStyleObject.test.js ├── locale.js ├── locale.test.js ├── round.js ├── steps │ ├── approximate.js │ ├── approximate.test.js │ ├── getStep.js │ ├── getStep.test.js │ ├── getStepDenominator.js │ ├── getStepDenominator.test.js │ ├── getStepMinTime.js │ ├── getStepMinTime.test.js │ ├── getTimeToNextUpdate.js │ ├── getTimeToNextUpdate.test.js │ ├── getTimeToNextUpdateForUnit.js │ ├── getTimeToNextUpdateForUnit.test.js │ ├── helpers.js │ ├── helpers.test.js │ ├── index.js │ ├── renameLegacyProperties.js │ ├── renameLegacyProperties.test.js │ ├── round.js │ ├── round.test.js │ └── units.js └── style │ ├── approximate.js │ ├── approximateTime.js │ ├── approximateTime.test.js │ ├── getStyleByName.js │ ├── mini.js │ ├── mini.test.js │ ├── miniMinute.js │ ├── miniMinute.test.js │ ├── miniMinuteNow.js │ ├── miniMinuteNow.test.js │ ├── miniNow.js │ ├── miniNow.test.js │ ├── renameLegacyProperties.js │ ├── renameLegacyProperties.test.js │ ├── round.js │ ├── round.test.js │ ├── roundMinute.js │ ├── roundMinute.test.js │ ├── twitter.js │ ├── twitter.test.js │ ├── twitterFirstMinute.js │ ├── twitterFirstMinute.test.js │ ├── twitterMinute.js │ ├── twitterMinute.test.js │ ├── twitterMinuteNow.js │ ├── twitterMinuteNow.test.js │ ├── twitterNow.js │ └── twitterNow.test.js ├── steps ├── index.cjs ├── index.cjs.js ├── index.js └── package.json └── test ├── TimeAgo.js ├── addLabels.test.js ├── exports.cache.test.js ├── exports.gradation.test.js ├── exports.prop-types.test.js ├── exports.steps.test.js ├── exports.test.js ├── locale └── de.test.js ├── setup.js └── setupLocales.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env" 4 | ], 5 | 6 | "plugins": [ 7 | ["@babel/plugin-transform-for-of", { loose: true }], 8 | "@babel/plugin-syntax-import-assertions" 9 | ], 10 | 11 | "env": { 12 | "es6": { 13 | "presets": [ 14 | ["@babel/preset-env", { modules: false }] 15 | ] 16 | }, 17 | "test": { 18 | "plugins": ["istanbul"] 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # testing package 2 | /javascript-isomorphic-render-*.tgz 3 | 4 | # test coverage folder 5 | /coverage/ 6 | /.nyc_output/ 7 | 8 | # npm modules 9 | # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git 10 | /node_modules/ 11 | 12 | # npm errors 13 | npm-debug.log 14 | 15 | # github pages 16 | /gh-pages/ 17 | 18 | # for OS X users 19 | .DS_Store 20 | 21 | # cache files for sublime text 22 | *.tmlanguage.cache 23 | *.tmPreferences.cache 24 | *.stTheme.cache 25 | 26 | # workspace files are user-specific 27 | *.sublime-workspace 28 | 29 | # webpack build target folder 30 | /modules/ 31 | /commonjs/ 32 | 33 | # NUL 34 | NUL 35 | 36 | # browser builds 37 | /bundle/ 38 | 39 | # locale data files 40 | /locale/ -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # git 2 | .gitignore 3 | .gitattributes 4 | 5 | # Babel 6 | .babelrc 7 | 8 | # Sources aren't needed for npm 9 | /source/ 10 | 11 | # testing package 12 | /javascript-isomorphic-render-*.tgz 13 | 14 | # Travis CI 15 | .travis.yml 16 | 17 | # test coverage folder 18 | /coverage/ 19 | /.nyc_output/ 20 | 21 | # npm errors 22 | npm-debug.log 23 | 24 | # github pages 25 | /gh-pages/ 26 | 27 | # for OS X users 28 | .DS_Store 29 | 30 | # cache files for sublime text 31 | *.tmlanguage.cache 32 | *.tmPreferences.cache 33 | *.stTheme.cache 34 | 35 | # workspace files are user-specific 36 | *.sublime-workspace 37 | *.sublime-project 38 | 39 | # webpack is used in development 40 | /webpack.config.babel.js 41 | 42 | # tests aren't needed for npm 43 | /test/ -------------------------------------------------------------------------------- /.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "@babel/register" 4 | ], 5 | "reporter": [ 6 | "lcov", 7 | "text-summary" 8 | ], 9 | "include": [ 10 | "source/**/*.js" 11 | ], 12 | "exclude": [ 13 | "source/PropTypes.js", 14 | "**/*.test.js" 15 | ], 16 | "sourceMap": false, 17 | "instrument": false, 18 | "cache": true, 19 | "all": true 20 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "stable" 4 | sudo: false 5 | script: 6 | - "npm run test-coverage" 7 | after_success: 8 | - "npm install coveralls && npm run coveralls" -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 35 | 36 | 2.4.0 / 19.05.2022 37 | ================== 38 | 39 | * Moved the package to use "ES Modules" exports. 40 | 41 | 2.3.13 / 11.02.2022 42 | ================== 43 | 44 | [Fixed](https://github.com/catamphetamine/javascript-time-ago/issues/60) the CDN bundle `javascript-time-ago.js` when it exported the `TimeAgo` class as a `default` property instead of exporting the `TimeAgo` class itself. 45 | 46 | 2.3.6 / 25.05.2021 47 | ================== 48 | 49 | * [Added](https://github.com/catamphetamine/javascript-time-ago/pull/47) `mini` style (aka `twitter` style) for some locales: `da`, `sv`, `nl`, `it`, `fr`, `es`. By [@trustpilot](https://github.com/trustpilot). 50 | 51 | 2.3.5 / 12.05.2021 52 | ================== 53 | 54 | * Added [additional `pt` locale styles](https://github.com/catamphetamine/javascript-time-ago/pull/45) by [Victor Biasibetti](https://github.com/victorbiasibetti). 55 | 56 | 2.3.3 / 11.11.2020 57 | ================== 58 | 59 | * Changed the default `style` from `"approximate"` (legacy) to `"round-minute"`. This isn't a "breaking change" because no application would be "broken" by something like that, and relative time would still be shown in a similar way, only without too much approximation. 60 | 61 | 2.3.1 / 20.10.2020 62 | ================== 63 | 64 | * (advanced) Renamed `getMinTimeToFrom()` to `getMinTimeForUnit()`. 65 | 66 | 2.3.0 / 14.10.2020 67 | ================== 68 | 69 | * `test(timestamp)` function of a step is now deprecated. Use `minTime(timestamp)` function instead. 70 | 71 | * Fixed `getTimeToNextUpdate()`. 72 | 73 | * Renamed `"mini-time"` labels to `"mini"`. 74 | 75 | * Added styles: `"mini"`, `"mini-now"`, `"mini-minute"`, `"mini-minute-now"`. 76 | 77 | * Added a new `round` property (described in the readme): it can be `"round"` or `"floor"`. The default is `"round"`. 78 | 79 | * (Could be a breaking change for those who read `"tiny"` from JSON files directly) Removed "tiny" labels from JSON files. `"tiny"` labels type name still works. 80 | 81 | 2.2.9 / 14.10.2020 82 | ================== 83 | 84 | * Fixed `"twitter-..."` styles. 85 | 86 | 2.2.8 / 12.10.2020 87 | ================== 88 | 89 | * Added `"twitter-minute-now"` style. 90 | 91 | * The threshold for `"now"` -> `"1m"`/`"1 minute ago"` is now 30 seconds rather than 40 seconds. 92 | 93 | 2.2.6 / 12.10.2020 94 | ================== 95 | 96 | * Changed `"twitter"` style: doesn't output `"now"` for 0 seconds. 97 | 98 | * Added `"twitter-now"` style that outputs `"now"` for 0 seconds. 99 | 100 | 2.2.5 / 11.10.2020 101 | ================== 102 | 103 | * Added `addDefaultLocale()` static function (similar to `addLocale()` but also calls `setDefaultLocale()`). 104 | 105 | * `"twitter"` style used to output `"now"` for 0 seconds. Then it was changed to `"0s"`. Now it has been [changed](https://github.com/catamphetamine/javascript-time-ago/issues/38) to `"now"` again. 106 | 107 | * Added "CDN" section in the readme that documents using the library with `