Humanizer
Humanizer copied to clipboard
`DateOnly` from DateTime.MinValue returns "2 months ago"
When I use DateOnly
and want to put this into a readable form with Humanizer, I get the error that "2 months ago" comes out for DateTime.MinValue
. If I use DateTime, then I get the expected result of "2022 years ago".
Examples:
DateOnly.FromDateTime(DateTime.MinValue).Humanize(); // returns "2 months ago"
DateTime.MinValue.Humanize(); // returns "2022 years ago"
The workaround for this is to add:
.ToDateTime(TimeOnly.MinValue).Humanize()
https://github.com/Humanizr/Humanizer/blob/937e827b8d664ce800b31160e51e8b2eca95fadc/src/Humanizer/DateTimeHumanizeStrategy/DateTimeHumanizeAlgorithms.cs#L158-L163
Does this need to use DayNumber
instead of DayOfYear
? I have a feeling that the current code doesn't work well with >1 year differences.
Probably related to #1186 or solved by it, if it gets a new implementation.