Is there an easy way (maybe built in solution) to convert TimeSpan
to localized string? For example new TimeSpan(3, 5, 0);
would be converted to 3 hours, 5minutes
(just in polish language).
I can of course create my own extension:
public static string ConvertToReadable(this TimeSpan timeSpan) {
int hours = timeSpan.Hours;
int minutes = timeSpan.Minutes;
int days = timeSpan.Days;
if (days > 0) {
return days + " dni " + hours + " godzin " + minutes + " minut";
} else {
return hours + " godzin " + minutes + " minut";
}
}
But this gets complicated if i want to have proper grammar involved.