mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 23:42:55 +08:00
Cleanup
This commit is contained in:
parent
82209aed82
commit
c7e20b34ba
@ -10,27 +10,21 @@ namespace osu.Game.Utils
|
|||||||
public static class HumanizerUtils
|
public static class HumanizerUtils
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Humanizes a string using the system culture, then falls back if one cannot be found.
|
/// Turns the current or provided date into a human readable sentence
|
||||||
/// <remarks>
|
|
||||||
/// A localization lookup failure will throw an exception of type <see cref="ArgumentException"/>
|
|
||||||
/// </remarks>
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dateTimeOffset">The time to humanize.</param>
|
/// <param name="input">The date to be humanized</param>
|
||||||
/// <returns>A humanized string of the given time.</returns>
|
/// <returns>distance of time in words</returns>
|
||||||
public static string Humanize(DateTimeOffset dateTimeOffset)
|
public static string Humanize(DateTimeOffset input)
|
||||||
{
|
{
|
||||||
string offset;
|
// this works around https://github.com/xamarin/xamarin-android/issues/2012 and https://github.com/Humanizr/Humanizer/issues/690#issuecomment-368536282
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
offset = dateTimeOffset.Humanize();
|
return input.Humanize();
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
offset = dateTimeOffset.Humanize(culture: new CultureInfo("en-US"));
|
return input.Humanize(culture: new CultureInfo("en-US"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user