Skip to content

Commit

Permalink
[Test Fix] Fix test fail on non-English locale (SR-15345) (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Oct 27, 2021
1 parent d6bfe19 commit 2cdc1e4
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,18 @@ public class DocumentationContentRenderer {

/// Returns the given amount of minutes as a string, for example: "1hr 10min".
func formatEstimatedDuration(minutes: Int) -> String? {
#if os(Linux)
// DateComponentsFormatter is unimplemented in Linux (rdar://59787899).
let hours = minutes / 60
let minutes = minutes % 60
return "\(hours > 0 ? "\(hours)hr " : "")\(minutes)min"
#else
let dateFormatter = DateComponentsFormatter()
if #available(OSX 10.12, *) {
dateFormatter.unitsStyle = .brief
}
dateFormatter.allowedUnits = [.hour, .minute]

return dateFormatter.string(from: TimeInterval(minutes * 60))
#endif
// TODO: Use DateComponentsFormatter once it's available on Linux (rdar://59787899) and
// when Swift-DocC supports generating localized documentation (SR-15352), since
// DateComponentsFormatter formats content based on the user's locale.
// let dateFormatter = DateComponentsFormatter()
// if #available(OSX 10.12, *) {
// dateFormatter.unitsStyle = .brief
// }
// dateFormatter.allowedUnits = [.hour, .minute]
// return dateFormatter.string(from: TimeInterval(minutes * 60))
let hours = minutes / 60
let minutes = minutes % 60
return "\(hours > 0 ? "\(hours)hr " : "")\(minutes)min"
}

/// Returns a metadata role for an article, depending if it's a collection, technology, or a free form article.
Expand Down

0 comments on commit 2cdc1e4

Please sign in to comment.