`mini` returns -1m instead of 1m for some locales
andreialecu opened this issue · 5 comments
So I just tried this with Romanian, and it appears that 1 minute ago
returns -1m
instead of just 1m
.
There's the extra minus in a bunch of other styles in some places but not others. With the en
locale everything is fine.
Is the minus a bug?
So I just tried this with Romanian, and it appears that 1 minute ago returns
-1m
instead of just1m
.
This is the default behavior when no custom mini.json
style has been defined for a locale.
If one of those languages is your native one, send a pull request, along with a proof that it's your native language.
I could do that, but why would prepending the minus be the default behavior? Is there a good reason for it?
Besides the minus everything works fine for Romanian even without the custom mini.json
.
I could do that, but why would prepending the minus be the default behavior?
Because it's how it is defined in Unicode CLDR data in the narrow
style.
https://github.com/catamphetamine/relative-time-format#locales
English (no minuses):
https://github.com/unicode-cldr/cldr-dates-full/blob/master/main/en-US-POSIX/dateFields.json
Some other language (has minuses):
https://github.com/unicode-cldr/cldr-dates-full/blob/master/main/sn/dateFields.json
I think most languages except English have minuses defined in the CLDR.
French has them too for example:
https://github.com/unicode-org/cldr-json/blob/master/cldr-json/cldr-dates-full/main/fr/dateFields.json
However, this library is supposed to return the time ago, so it's a bit inconsistent to return a minus from it.
I understand it's an upstream problem though, but it should maybe be mentioned as a caveat in the README.
#50 will fix it for romanian, but this is likely to be a problem for other languages as well.
I understand it's an upstream problem though, but it should maybe be mentioned as a caveat in the README.
Well, maybe.
I've added a comment in the README.
https://github.com/catamphetamine/javascript-time-ago#mini