Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Add formatter for a11y string #51

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

Conversation

schlagelk
Copy link

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.

@googlebot
Copy link

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. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@schlagelk
Copy link
Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Contributor

@taquitos taquitos left a 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)
Copy link
Contributor

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:

  1. 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.
  2. 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.
  3. 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!

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

Successfully merging this pull request may close these issues.

4 participants