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

Space between value and unit #39

Closed
arnitkun opened this issue Sep 9, 2019 · 2 comments
Closed

Space between value and unit #39

arnitkun opened this issue Sep 9, 2019 · 2 comments

Comments

@arnitkun
Copy link

arnitkun commented Sep 9, 2019

pretty-ms does not put a space between numbers and units unless the verbose option is enabled.

However the standard as per wikipedia:

"The International System of Units (SI) recommends inserting a space between a number and a unit of measurement units and between units in compound units, but never between a prefix and a base unit.

5.0 cm not 5.0cm or 5.0 c m
45 kg not 45kg or 45 k g...

The only exception to this rule in the SI the symbolic notation of angles: degree (e.g. 30°), minute of arc (e.g. 22′), and second of arc (e.g. 8″)."
http://en.wikipedia.org/wiki/Space_(punctuation)#Spaces_and_unit_symbols

Why does pretty-ms deviate from the standard? Or am I missing something?
I understand that it is very possible to change the result string in the code itself. I just wanted to know.

@sindresorhus
Copy link
Owner

You are the first to bring this up. It's mostly for stylistic and readability reasons. Also, the name of this package is pretty-ms, not si-correct-ms 😛.

5h 1m 45s
5 h 1 m 45 s

The second one is much less readable.

You could argue that it should have two spaces between components then, but that doesn't look very good either:

5 h  1 m  45 s

Apple doesn't use space between the unit either when showing abbreviated time on iOS/macOS either.

Closing this as I don't intend to change it or add an option to change it.

@manfromanotherland
Copy link

manfromanotherland commented Mar 19, 2024

I was facing the same issue. Here’s a workaround to add a space between value and unit:

prettyMs(value).replace(/(\d+)(\D+)/, '$1 $2')

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

3 participants