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

Fix display of time units as per the SI #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

getsnoopy
Copy link

The SI requires symbols (not abbreviations) for units and spaces
between quantities and their unit symbols. This commit fixes these
issues in the time formatter.

The SI requires symbols (not abbreviations) for units and spaces
between quantities and their unit symbols. This commit fixes these
issues in the time formatter.
Copy link
Member

@kylekatarnls kylekatarnls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, 👋 Thanks for your contribution. 👍

I think we're fine with "scientist" compressed unit style. We can see the same in various other libraries :

Sorry for the late feedback. 🙏

@getsnoopy
Copy link
Author

@kylekatarnls The SI is the "scientist unit style". And it's actually not a matter of style; it's the only proper way to write units. 5m would mean "5 million", while 5 m would mean "5 metres"; similarly, 5s would mean "fives" while 5 s means "5 seconds". The current symbols are incorrect.

I'm not sure about Carbon (I'll submit a pull request there as well), but as for CLDR, they had it incorrectly in their previous library versions. I'm already working with them to fix it in the next version of CLDR.

@kylekatarnls
Copy link
Member

Oh, that would be a wide change for CLDR as it is driving indirectly a lot of other libraries and I think it's there for years, maybe ProtonVPN also took it from there. And sure if it changes there, we should really consider to change too.

Good to know the space matters. Thanks for the tip. I would still make myself advocate for the devil, we are here in a context where there is no ambiguity about the meaning in good faith (it will appear next to "duration"). So probably there is to be considered the readability vs. SI-compliance and balance it, maybe if we go for a space before and after we should also add a comma between values.

@kylekatarnls
Copy link
Member

I also checked other clients (such as the Android VPN app) and it sounds we're doing the same (compressed) there. So we should probably take a decision at product level to apply to all.

@getsnoopy
Copy link
Author

it is driving indirectly a lot of other libraries and I think it's there for years, maybe ProtonVPN also took it from there. And sure if it changes there, we should really consider to change too.

Yes, it is sort of the de facto internationalization library, so it is unfortunate that the mistake was in there. But it is going to be fixed, so it should be fixed here as well.

I would still make myself advocate for the devil, we are here in a context where there is no ambiguity about the meaning in good faith (it will appear next to "duration").

Being an advocate for the devil does not sound like a glamorous career :) But while the label might be there, the advantage with the SI is that context never matters or is needed. 5 min means "5 minutes" anywhere in the world, in any language/script, and with or without any context. 5 m similarly means "5 metres" universally; trying to force the reader to relearn what they already have known their whole life to mean "5 minutes" is not good UX nor productive.

So probably there is to be considered the readability vs. SI-compliance and balance it, maybe if we go for a space before and after we should also add a comma between values.

While the comma is a style issue, I'd argue it's unnecessary. Any mixed units in the SI (or otherwise) are written with just spaces; for example, heights in US customary units or imperial units are written as 5 ft 9 in and not as 5 ft, 9 in. Similarly with angular units (e.g., for DMS GPS coordinates), for example: 5° 10′ 22″ instead of 5°, 10′, 22″.

@kylekatarnls
Copy link
Member

Readability issue was not about 5 min vs. 5 m, but about 5s vs. 5 s, when you put all together:

1 d 2 h 3 min 4 s the eyes need to jump from letter to digit and one can hardly make the groups in your mind.
1d 2h 3min 4s instead helps you to make the correct grouping faster, and as true as the SI can be, being easily readable and accessible is important too (having in mind the various vision problems that exist).

And so that's why I was proposing to work around with the coma. This problem actually does not exist with 5° 10′ 22″ because there is no space between the digit and the related unit + the unit is extra-small, so visually this is pretty easy to read (group the number with the unit related to it). Then with 5 ft 9 in, the issue is still not that bad, because you have only 2 groups and the fact that the unit is 2-letters long is also helping.

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

Successfully merging this pull request may close these issues.

2 participants