* Changed LastPlayed field from string to nullable DateTime Added ApplicationData.LastPlayedString property Added NullableDateTimeConverter for the DateTime->string conversion in Avalonia * Added migration from string-based last_played to DateTime-based last_played_utc * Updated comment style * Added MarkupExtension to NullableDateTimeConverter and changed its usage Cleaned up leftover usings * Missed one comment
38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using Avalonia.Data.Converters;
|
|
using Avalonia.Markup.Xaml;
|
|
using Ryujinx.Ava.Common.Locale;
|
|
using System;
|
|
using System.Globalization;
|
|
|
|
namespace Ryujinx.Ava.UI.Helpers
|
|
{
|
|
internal class NullableDateTimeConverter : MarkupExtension, IValueConverter
|
|
{
|
|
private static readonly NullableDateTimeConverter _instance = new();
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value == null)
|
|
{
|
|
return LocaleManager.Instance[LocaleKeys.Never];
|
|
}
|
|
|
|
if (value is DateTime dateTime)
|
|
{
|
|
return dateTime.ToLocalTime().ToString(culture);
|
|
}
|
|
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public override object ProvideValue(IServiceProvider serviceProvider)
|
|
{
|
|
return _instance;
|
|
}
|
|
}
|
|
} |