- Instead of performing two steps when adding a language —
import en from "javascript-time-ago/locale/en"and thenTimeAgo.addLocale(en)— only one step is required now —import "javascript-time-ago/locale/en". As a result, the code for adding languages is a bit shorter now. The older way with.addLocale()still works.
- Rewrote README.
- Added
refreshparameter. getTimeToNextUpdate: truenow returns a "capped"timeToNextUpdateby default — this is to work aroundsetTimeout()bug when the delay is longer than about24.85days.- The new "capping" behavior could be disabled by passing
getTimeToNextUpdateUncapped: trueoption.
- The new "capping" behavior could be disabled by passing
- Added
javascript-time-ago/full-date-formatterexport — it can be used to get the value for thetitleattribute of a<time/>HTML tag.
- Moved the package to use "ES Modules" exports.
Fixed the CDN bundle javascript-time-ago.js when it exported the TimeAgo class as a default property instead of exporting the TimeAgo class itself.
- Added
ministyle (akatwitterstyle) for some locales:da,sv,nl,it,fr,es. By @trustpilot.
- Added additional
ptlocale styles by Victor Biasibetti.
- Changed the default
stylefrom"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.
- (advanced) Renamed
getMinTimeToFrom()togetMinTimeForUnit().
-
test(timestamp)function of a step is now deprecated. UseminTime(timestamp)function instead. -
Fixed
getTimeToNextUpdate(). -
Renamed
"mini-time"labels to"mini". -
Added styles:
"mini","mini-now","mini-minute","mini-minute-now". -
Added a new
roundproperty (described in the readme): it can be"round"or"floor". The default is"round". -
(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.
- Fixed
"twitter-..."styles.
-
Added
"twitter-minute-now"style. -
The threshold for
"now"->"1m"/"1 minute ago"is now 30 seconds rather than 40 seconds.
-
Changed
"twitter"style: doesn't output"now"for 0 seconds. -
Added
"twitter-now"style that outputs"now"for 0 seconds.
-
Added
addDefaultLocale()static function (similar toaddLocale()but also callssetDefaultLocale()). -
"twitter"style used to output"now"for 0 seconds. Then it was changed to"0s". Now it has been changed to"now"again. -
Added "CDN" section in the readme that documents using the library with
<script/>tags (without a bundler).
-
Renamed steps'
unittoformatAs. The older name still works. Maybe it will be renamed to something else in some future. -
Renamed steps'
thresholdtominTime. The older name still works but is considered deprecated. -
Renamed steps'
threshold_for_idOrUnit: valuetominTime: { id: value }. The older way still works but is considered deprecated. MaybeminTime: {}object will be deprecated too in some future. -
Added
test(date, { now, future })function to steps: it can be an alternative tominTime. See "twitter" style for an example. -
Added a third argument to steps'
format()function: an object having shape{ formatAs(unit, amount): string, future: boolean }. -
Added
TimeAgo.addLabels(locale, name, labels)function, that can be used to expand localized time labels. -
Added
"twitter-first-minute"style: same as"twitter"but doesn't output anything before the first minute. This is how"twitter"style worked initially. -
Added
getTimeToNextUpdatefeature (see README). -
Updated
relative-time-formatto the latest version:0.1.x->1.0.0. -
Locale files are now
*.jsonfiles. There's noquantifyfunction there now: now it's just labels.{locale}/index.jsfiles are still there just for legacy compatibility. -
Added the ability to use native
Intl.RelativeTimeFormatandIntl.PluralRulesinstead of the polyfills: in this case, passpolyfill: falseoption when creating aTimeAgoinstance. -
The bundle is now generated by Rollup rather than Webpack.
-
Custom styles: renamed
gradationtostepsandflavourtolabels. The older names still work but are considered deprecated. -
factorproperty of a "step" is now not required: if not present, it's assumed equal to theunitin seconds (for example, the defaultfactoris60 * 60forunit: "hour").
-
Renamed
"default"style to"round". The older name still works but is considered deprecated. -
Added
"round-minute"style: same as"round"but without seconds. -
Renamed
"time"style to"approximate-time". The older name still works but is considered deprecated. -
Renamed
"canonical"gradation to"round". The older name still works but is considered deprecated. -
Renamed
"tiny"time labels style to"mini-time"."tiny"time labels style still works but is considered deprecated. -
(internals) Renamed
tiny.jsonlocale files tomini-time.json. Removednowunit frommini-time.json. -
(internals)
"approximate"(previously"convenient") style now useslonglabels instead oflong-convenient.json. -
(internals) Removed
nowunit frommini-time.jsonfiles. -
(internals) Removed
long-convenient.jsonandshort-convenient.jsonfiles:long.jsonandshort.jsonin combination withnow.jsonare used instead.
-
(could be considered a breaking change, but it doesn't actually break any apps)
"twitter"style now outputs something like"1s"in case of"1 second ago". Previously it didn't output anything when the time difference was less than a minute. The rationale for the change is that Twitter actually does output seconds when the time difference is less than a minute. There's still a small difference from Twitter: Twitter outputs"now"in case of"0 seconds ago"while this library outputs"0s"— the rationale is that "now" could be too long is different languages, and also it would look too contrasty compared to its "sibling""Xs"time labels. -
Added
"default"style (longtime labels +canonicalgradation). Update: it's now called"round"instead of"default". -
Added
futureoption on.format(value, style, options)function: it determines, whether to use the"future"variant of"now"when formatting0time difference. By default, it uses the"past"variant of"now"when formatting0time difference:"just now"instead of"in a moment". -
(miscellaneous) Added dedicated
"now.json"labels for"now"time unit.
- Added
"tiny"time labels for"de"locale.
-
Moved
RelativeTimeFormatto a separaterelative-time-formatpackage. -
(breaking change) Removed
.locale()static function. Use.addLocale()instead. -
(breaking change)
flavourproperty renamed in non-single-word cases: underscores (_) got replaced with dashes (-). Examples:short_convenient->short-convenient,long_convenient->long-convenient,short_time->short-time,long_time->long-time. The relevant keys in localeindex.jsfiles got renamed the same way. -
(breaking change)
RelativeTimeFormatis no longer exported from this library. -
(could be a breaking change) Re-did
/prop-types,/gradation,/cacheexports as sub-packages. This could possibly change their import behavior. Maybe/prop-typesdid change — I changed some export strategies for it. -
(unlikely a breaking change)
yue-Hantlocale removed (due to its removal from CLDR). -
(unlikely to be a breaking change) Removed handling for a case when "now" unit had "past"/"future" which is an object of quantifier messages instead of a string. The rationale that having "now" unit with "past"/"future" which are objects of quantifier messages wouldn't make sense because "now" is a moment and one can't differentiate between "past moment", "current moment" and "next moment" in real life.
-
Resolved cyclic dependency between
JavascriptTimeAgo.jsandRelativeTimeFormat.js. -
JavascriptTimeAgo.default_localevariable no longer exists (it wasn't public or documented).
-
Added
.addLocale()alias for.locale()function (better naming). The old.locale()function name is now deprecated and will be removed in some next major version release. -
Added
RelativeTimeFormat.addLocale()proxy function which simply callsJavascriptTimeAgo.addLocale().
- Refactored
twitterstyle and styles overall: style can now havethreshold(now)function and also gradation step can haveformat(value, locale)function instead ofunit.
- Renamed
overridetocustomfor styles
- Renamed
fuzzystyle totime. - Refactored
gradations andstyles. gradationis now not being exported fromindex.jsalong withday,monthandyear(one can stillimportit manually fromgradation.js).es6folder got renamed tomodulesbuildfolder got renamed tocommonjs
- Renamed
pluraltoquantifyinside locale data. - Implemented
Intl.RelativeTimeFormatproposal polyfill which is now being exported.
- (can be a breaking change for custom styles) Renamed
just-nowunit tonowandxxx-conciseflavour toxxx_time(+ flavour.jsonfiles got renamed accordingly).
- (breaking change) When defining a custom
styleitsoverride()function takesdateandtimeparameters: nowdateparameter ofoverride()is not guaranteed to be set (can be inferred fromtime).
-
(breaking change) Due to a long-standing engineering flaw in
intl-messageformatlibrary (the locale data loading process) I dismissed it and this library is now using raw CLDR locale data instead so built-in locale data now holds an extra property: thepluralfunction taking a number and returning the pluralization type of that number ("one", "few", etc). Therefore, if adding raw CLDR locale data for locales which are not built-in this pluralization function must be passed as the second argument to.locale(localeDataCLDR, pluralsClassifier). -
(breaking change)
javascriptTimeAgo.stylesis no more accesible: passstyleas a string instead. -
(breaking change)
localesfolder inside the package renamed tolocale(e.g.javascript-time-ago/locales/en->javascript-time-ago/locale/en). -
style.flavourcan now be an array
- Changed
yesterdayandtomorrowlabels for Russian localization
- Moved
intl-messageformattopeerDependencies
- Initial release