mirror of
https://github.com/bitwarden/mobile.git
synced 2024-06-25 10:26:02 +02:00
44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using System;
|
|
using Bit.Core.Resources.Localization;
|
|
|
|
namespace Bit.App.Utilities
|
|
{
|
|
public static class A11yExtensions
|
|
{
|
|
public enum TimeSpanVerbalizationMode
|
|
{
|
|
HoursAndMinutes,
|
|
Hours
|
|
}
|
|
|
|
public static string Verbalize(this TimeSpan timeSpan, TimeSpanVerbalizationMode mode)
|
|
{
|
|
if (mode == TimeSpanVerbalizationMode.Hours)
|
|
{
|
|
if (timeSpan.TotalHours == 1)
|
|
{
|
|
return AppResources.OneHour;
|
|
}
|
|
|
|
return string.Format(AppResources.XHours, timeSpan.TotalHours);
|
|
}
|
|
|
|
if (timeSpan.Hours == 1)
|
|
{
|
|
if (timeSpan.Minutes == 1)
|
|
{
|
|
return AppResources.OneHourAndOneMinute;
|
|
}
|
|
return string.Format(AppResources.OneHourAndXMinute, timeSpan.Minutes);
|
|
}
|
|
|
|
if (timeSpan.Minutes == 1)
|
|
{
|
|
return string.Format(AppResources.XHoursAndOneMinute, timeSpan.Hours);
|
|
}
|
|
|
|
return string.Format(AppResources.XHoursAndYMinutes, timeSpan.Hours, timeSpan.Minutes);
|
|
}
|
|
}
|
|
}
|