29 lines
1.5 KiB
C#
29 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AnotherReplayReader.Utils
|
|
{
|
|
public readonly struct ShortTimeSpan : IEquatable<ShortTimeSpan>, IComparable<ShortTimeSpan>, IComparable
|
|
{
|
|
public readonly TimeSpan Value;
|
|
|
|
public ShortTimeSpan(TimeSpan value) => Value = value;
|
|
public static implicit operator TimeSpan(ShortTimeSpan span) => span.Value;
|
|
public static implicit operator ShortTimeSpan(TimeSpan value) => new(value);
|
|
public override string ToString() => $"{(int)Value.TotalMinutes:00}:{Value.Seconds:00}";
|
|
|
|
public int CompareTo(ShortTimeSpan other) => Value.CompareTo(other.Value);
|
|
public int CompareTo(object obj) => obj is ShortTimeSpan span ? CompareTo(span) : 1;
|
|
public override bool Equals(object? obj) => obj is ShortTimeSpan span && Equals(span);
|
|
public bool Equals(ShortTimeSpan other) => Value.Equals(other.Value);
|
|
public override int GetHashCode() => Value.GetHashCode();
|
|
public static bool operator ==(ShortTimeSpan left, ShortTimeSpan right) => left.Equals(right);
|
|
public static bool operator !=(ShortTimeSpan left, ShortTimeSpan right) => !(left == right);
|
|
public static bool operator <(ShortTimeSpan left, ShortTimeSpan right) => left.CompareTo(right) < 0;
|
|
public static bool operator >(ShortTimeSpan left, ShortTimeSpan right) => left.CompareTo(right) > 0;
|
|
}
|
|
}
|