Is there an easy way (possibly built into the solution) to convert TimeSpanto a localized string? For example, it new TimeSpan(3, 5, 0);will be converted to 3 hours, 5minutes(Polish only).
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 it gets complicated if I want to have the correct grammar.
source
share