From a8eb25441cb4288e5b77031e94233ec2b5b8c067 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Wed, 28 Feb 2024 22:18:01 -0500 Subject: [PATCH] Stringify Time Zones like Horizon --- src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs | 2 +- src/Ryujinx.Ava/UI/Models/TimeZone.cs | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs b/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs index 876d51f71..72852192f 100644 --- a/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs +++ b/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Ava.UI.Helpers } var timeZone = (TimeZone)value; - return string.Format("{0} {1} {2}", timeZone.UtcDifference, timeZone.Location, timeZone.Abbreviation); + return timeZone.ToString(); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/src/Ryujinx.Ava/UI/Models/TimeZone.cs b/src/Ryujinx.Ava/UI/Models/TimeZone.cs index 950fbce43..65fe6c848 100644 --- a/src/Ryujinx.Ava/UI/Models/TimeZone.cs +++ b/src/Ryujinx.Ava/UI/Models/TimeZone.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Ava.UI.Models { - internal class TimeZone + public class TimeZone { public TimeZone(string utcDifference, string location, string abbreviation) { @@ -9,6 +9,21 @@ namespace Ryujinx.Ava.UI.Models Abbreviation = abbreviation; } + public string ToString() + { + // Prettifies location strings eg: + // "America/Costa_Rica" -> "Costa Rica" + var location = Location.Replace("_", " "); + + if (location.Contains("/")) + { + var parts = location.Split("/"); + location = parts[1]; + } + + return $"{UtcDifference} - {location}"; + } + public string UtcDifference { get; set; } public string Location { get; set; } public string Abbreviation { get; set; }