Skip to content

Commit 58337d6

Browse files
authored
Address Foundation-related FIXME in GeneratorCLI.swift (#132)
1 parent 617d43f commit 58337d6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Sources/GeneratorCLI/GeneratorCLI.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ extension GeneratorCLI {
287287
}
288288
}
289289

290-
// FIXME: replace this with a call on `.formatted()` on `Duration` when it's available in swift-foundation.
291290
import Foundation
292291

293292
extension Duration {
@@ -298,10 +297,18 @@ extension Duration {
298297
let components = Calendar.current.dateComponents([.hour, .minute, .second], from: reference, to: date)
299298

300299
if let hours = components.hour, hours > 0 {
300+
#if !canImport(Darwin) && compiler(<6.0)
301301
return String(format: "%02d:%02d:%02d", hours, components.minute ?? 0, components.second ?? 0)
302+
#else
303+
return self.formatted()
304+
#endif
302305
} else if let minutes = components.minute, minutes > 0 {
306+
#if !canImport(Darwin) && compiler(<6.0)
303307
let seconds = components.second ?? 0
304308
return "\(minutes) minute\(minutes != 1 ? "s" : "") \(seconds) second\(seconds != 1 ? "s" : "")"
309+
#else
310+
return "\(self.formatted(.time(pattern: .minuteSecond))) seconds"
311+
#endif
305312
} else {
306313
return "\(components.second ?? 0) seconds"
307314
}

0 commit comments

Comments
 (0)