-
Notifications
You must be signed in to change notification settings - Fork 62
Add formatter for a11y string #51
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
var accessibleDurationString: String { | ||
return TimeInterval.accessibleIntervalFormatter.string(from: self) ?? "" | ||
return TimeInterval.accessibleIntervalFormatter.string(from: self, appending: fractional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're currently discussing this path because of a few issues:
- In an ideal world, we'd use our existing DateComponentsFormatter to simply use milliseconds since it does the localization for us including locale ordering, etc. But obviously DCF doesn't support anything smaller than seconds.
- The issue with appending this formatted string onto the end of the existing a11y string is that, in some locales, this might not be correct. We're not entirely sure, but given the history of how locales work it's entirely possible there's a locale in which milliseconds come first, perhaps.
- We don't have a good solution to present instead 😅
We'll discuss a bit more internally and circle back to you on this. Greatly appreciate your PR and your patience. Thanks!
Checklist
Motivation and Context
Milliseconds do not to really seem be supported in any of the date formatting or NSCalendar APIs. Because of that, there is issue #19.
Description
This PR adds a fractional seconds calculation to TimeInterval and a string formatter to DateComponentsFormatter that will append any available fractional seconds as milliseconds (it also adds a localizable string for "milliseconds"). This PR includes s a unit test to verify said code.