Can DateComponentsFormatter format fractional seconds?

I want to print, for example, a value of 1.5 as "1.5 s", for example, the Safari timeline, and I'm trying to use a DateComponentsFormatter for it.

Unfortunately, its .allowedUnits limited to only .second (although the enumeration has .nanosecond ). I tried to set .allowsFractionalUnits = true , but I still get "0 sec."

Is there a way to get fractional seconds from a DateComponentsFormatter?

+5
source share

Source: https://habr.com/ru/post/1266488/


All Articles