feat: implement month syncing.

This commit is contained in:
rabbitism
2024-06-23 04:34:23 +08:00
parent c88258cdd5
commit d8119aaeaa
6 changed files with 90 additions and 30 deletions

View File

@@ -1,6 +1,6 @@
namespace Ursa.Controls;
public sealed class CalendarContext(int? year = null, int? month = null, int? startYear = null, int? endYear = null)
public sealed class CalendarContext(int? year = null, int? month = null, int? startYear = null, int? endYear = null): IComparable<CalendarContext>
{
public int? Year { get; } = year;
public int? Month { get; } = month;
@@ -64,4 +64,13 @@ public sealed class CalendarContext(int? year = null, int? month = null, int? st
{
return new CalendarContext(Year - 1, Month, StartYear, EndYear);
}
public int CompareTo(CalendarContext? other)
{
if (ReferenceEquals(this, other)) return 0;
if (ReferenceEquals(null, other)) return 1;
var yearComparison = Nullable.Compare(Year, other.Year);
if (yearComparison != 0) return yearComparison;
return Nullable.Compare(Month, other.Month);
}
}