mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System;
|
|
using System.Diagnostics.Contracts;
|
|
using System.Globalization;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Windows.Data;
|
|
|
|
namespace OwlCore.Wpf.Converters.Time.Numerical
|
|
{
|
|
/// <summary>
|
|
/// A converter that converts a given <see cref="long"/> to a <see cref="TimeSpan"/>.
|
|
/// </summary>
|
|
public sealed class LongToTimeSpanConverter : IValueConverter
|
|
{
|
|
/// <summary>
|
|
/// Converts a <see cref="long"/> to a <see cref="TimeSpan"/>.
|
|
/// </summary>
|
|
/// <param name="value">The <see cref="TimeSpan"/> to convert.</param>
|
|
/// <returns>A formatted string of the <see cref="TimeSpan"/>.</returns>
|
|
[Pure]
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static TimeSpan Convert(long value) => TimeSpan.FromMilliseconds(value);
|
|
|
|
/// <inheritdoc/>
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is long timeSpan)
|
|
{
|
|
return Convert(timeSpan);
|
|
}
|
|
|
|
return Convert(0);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|