ENikS/LINQ

GroupBy Date Bug?

gernei09 opened this issue · 1 comments

In JS/TS:

var dts = [new Date("1/1/19"), new Date("1/2/19"), new Date("1/1/19"), new Date("1/2/19"), new Date("1/3/19"), new Date("1/4/19")];
Enumerable.From(dts).GroupBy(e => e).Count(); // Get 6 expected 4

In C#:

var dts = new DateTime[] { new DateTime(2019, 1, 1), new DateTime(2019, 1, 1), new DateTime(2019, 1, 2), new DateTime(2019, 1, 2), new DateTime(2019, 1, 3), new DateTime(2019, 1, 4) };
dts.GroupBy(e => e).Count(); // Get 4 expected 4

I'd imagine there are reasons for this variation due to how each language compares dates, however I wanted to see how we can circumvent this to get the same result as C#?

ENikS commented

I do not think this should be fixed by the library. Used in each respective language it produces expected results. If you need consistence between languages you should provide custom comparer.