#formatstyle — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #formatstyle, aggregated by home.social.
-
The only usable ByteCountFormatStyle is decimal
Swift makes it relatively easy to format numbers as byte counts, with appropriate suffixes to indicate units and generally sensible auto-selection of scale factors. e.g.:
1234.formatted(.byteCount(style: .decimal))
1 kB(in English - results may vary depending on locale)
This is just a small subset of Swift's FormatStyle-based formatting capabilities, with which I have a bit of a love-hate relationship even when they're working correctly.
Alas, they don't always work correctly; some of [...]
https://wadetregaskis.com/the-only-usable-bytecountformatstyle-is-decimal/
-
The only usable ByteCountFormatStyle is decimal
Swift makes it relatively easy to format numbers as byte counts, with appropriate suffixes to indicate units and generally sensible auto-selection of scale factors. e.g.:
1234.formatted(.byteCount(style: .decimal))
1 kB(in English - results may vary depending on locale)
This is just a small subset of Swift's FormatStyle-based formatting capabilities, with which I have a bit of a love-hate relationship even when they're working correctly.
Alas, they don't always work correctly; some of [...]
https://wadetregaskis.com/the-only-usable-bytecountformatstyle-is-decimal/
-
The only usable ByteCountFormatStyle is decimal
Swift makes it relatively easy to format numbers as byte counts, with appropriate suffixes to indicate units and generally sensible auto-selection of scale factors. e.g.:
1234.formatted(.byteCount(style: .decimal))
1 kB(in English - results may vary depending on locale)
This is just a small subset of Swift's FormatStyle-based formatting capabilities, with which I have a bit of a love-hate relationship even when they're working correctly.
Alas, they don't always work correctly; some of [...]
https://wadetregaskis.com/the-only-usable-bytecountformatstyle-is-decimal/
-
Fucking FormatStyle
I have a bit of a love-hate relationship with Swift's FormatStyle-based formatting capabilities.
Text(progress.formatted(.percent.precision(.significantDigits(2))))
42%(in English - results may vary depending on locale)
On the pro side:
They're better than rolling your own formatting. Not just in terms of convenience, but in terms of correctness - they support localisation, for example. "42%" in English, "٤٢٪" in العربية (Arabic), "৪২%" in ?
সমীয়া [...]
-
Fucking FormatStyle
I have a bit of a love-hate relationship with Swift's FormatStyle-based formatting capabilities.
Text(progress.formatted(.percent.precision(.significantDigits(2))))
42%(in English - results may vary depending on locale)
On the pro side:
They're better than rolling your own formatting. Not just in terms of convenience, but in terms of correctness - they support localisation, for example. "42%" in English, "٤٢٪" in العربية (Arabic), "৪২%" in ?
সমীয়া [...]
-
Fucking FormatStyle
I have a bit of a love-hate relationship with Swift's FormatStyle-based formatting capabilities.
Text(progress.formatted(.percent.precision(.significantDigits(2))))
42%(in English - results may vary depending on locale)
On the pro side:
They're better than rolling your own formatting. Not just in terms of convenience, but in terms of correctness - they support localisation, for example. "42%" in English, "٤٢٪" in العربية (Arabic), "৪২%" in ?
সমীয়া [...]