Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mini returns -1m instead of 1m for some locales #49

Closed
andreialecu opened this issue Jun 17, 2021 · 5 comments
Closed

mini returns -1m instead of 1m for some locales #49

andreialecu opened this issue Jun 17, 2021 · 5 comments

Comments

@andreialecu
Copy link
Contributor

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?

@catamphetamine
Copy link
Owner

So I just tried this with Romanian, and it appears that 1 minute ago returns -1m instead of just 1m.

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.

@andreialecu
Copy link
Contributor Author

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.

@catamphetamine
Copy link
Owner

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

@andreialecu
Copy link
Contributor Author

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.

catamphetamine added a commit that referenced this issue Jun 17, 2021
@catamphetamine
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants