demo_trade/UI/Converters/ItemDateConverter.cs
2024-10-04 15:41:04 +03:00

31 lines
824 B
C#

using Avalonia.Data.Converters;
using Avalonia.Media;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tmds.DBus.Protocol;
namespace demo_trade.UI.Converters
{
public class ItemDateConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
var date = (DateOnly)value;
return new DateTimeOffset(new DateTime(date.Year, date.Month, date.Day));
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
var date = (DateTimeOffset)value;
return new DateOnly(date.Year, date.Month, date.Day);
}
}
}