Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test Fix] Fix test fail on non-English locale (SR-15345) #7

Merged
merged 2 commits into from
Oct 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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