ical.net
ical.net copied to clipboard
An error occurred while comparing two IDateTime values.
I found an error comparing two dates with different formats.
bei Ical.Net.DataTypes.CalDateTime.CompareTo(IDateTime dt) bei System.Collections.Generic.GenericComparer
1.Compare(T x, T y) bei System.Linq.EnumerableSorter2.CompareKeys(Int32 index1, Int32 index2) bei System.Linq.EnumerableSorter1.QuickSort(Int32[] map, Int32 left, Int32 right) bei System.Linq.EnumerableSorter1.Sort(TElement[] elements, Int32 count) bei System.Linq.OrderedEnumerable1.<GetEnumerator>d__1.MoveNext() bei System.Collections.Generic.List1..ctor(IEnumerable1 collection) bei System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
Example Code: `List<Ical.Net.DataTypes.CalDateTime> dates = new List<Ical.Net.DataTypes.CalDateTime>(); dates.Add(new Ical.Net.DataTypes.CalDateTime(DateTime.Today)); dates.Add(new Ical.Net.DataTypes.CalDateTime(DateTime.Today.ToUniversalTime()));
var datesSorted = dates.OrderBy(d => d).ToList();`
Issue still exists in 4.1.11. The problem appears if the compared dates represent the same instant but in different timezones. In this case the CalDateTime.CompareTo considers the values neither as greater, nor as less nor as equal, which results in throw new Exception("An error occurred while comparing two IDateTime values.");. See here.
Expected: Let CalDateTime.CompareTo consider two values as equal if they represent the same instant in different timezones.