1234567891011121314151617181920212223242526272829 |
- using System;
- using System.Collections.Generic;
- using Avalonia.Data.Converters;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Globalization;
- using System.IO;
- namespace AvaloniaApplicationTestNew.Resources
- {
- internal class DateConverter : IValueConverter
- {
- public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
- {
- if (value is DateTime) return new DateTimeOffset((DateTime)value, TimeSpan.Zero);
- return null;
- }
- public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
- {
- if(value is DateTimeOffset myDateTimeOffset)
- {
- return new DateTime(myDateTimeOffset.Year, myDateTimeOffset.Month, myDateTimeOffset.Day);
- }
- return null;
- }
- }
- }
|