mirror of
https://github.com/bitwarden/mobile
synced 2025-12-20 10:13:42 +00:00
add date and time formatting methods to localize service (#1616)
- uses Apple APIs for formatting on iOS - uses .Net APIs for formatting Android - implemented across project - remove unnecesary calls to DateTimeConverter
This commit is contained in:
@@ -100,5 +100,25 @@ namespace Bit.iOS.Core.Services
|
||||
Console.WriteLine(".NET Fallback Language/Locale:" + netLanguage + " (application-specific)");
|
||||
return netLanguage;
|
||||
}
|
||||
|
||||
public string GetLocaleShortDate(DateTime? date)
|
||||
{
|
||||
using (var df = new NSDateFormatter())
|
||||
{
|
||||
df.Locale = NSLocale.CurrentLocale;
|
||||
df.DateStyle = NSDateFormatterStyle.Short;
|
||||
return df.StringFor((NSDate)date);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetLocaleShortTime(DateTime? time)
|
||||
{
|
||||
using (var df = new NSDateFormatter())
|
||||
{
|
||||
df.Locale = NSLocale.CurrentLocale;
|
||||
df.TimeStyle = NSDateFormatterStyle.Short;
|
||||
return df.StringFor((NSDate)time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user