martinjw / Holiday

Calculate Public Holidays
MIT License
208 stars 82 forks source link

Support for DateOnly #119

Closed wdnijdam closed 7 months ago

wdnijdam commented 7 months ago

Since net7 we prefer to use DateOnly instead of DateTime for date calculations

Please add a compiler switch using DateOnly starting from net7

The DateOnly type more clearly expresses the intention and furthermore date calculations like .AddDays() are more efficient.

martinjw commented 7 months ago

Agreed DateOnly is preferable, but it is a breaking change, and it will break when people upgrade their main project with this dependency- DateOnly != DateTime

It is possible to add overloads to some methods to take a DateOnly, but all the underlying logic still uses DateTime:

public bool IsPublicHoliday(DateOnly do) => IsPublicHoliday(dt.ToDateTime(new TimeOnly(0, 0)));

At some point I will do a major version change, and I will look at this again then.