Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support For DateOnly and TimeOnly #513

Open
RHaughton opened this issue Jul 14, 2023 · 4 comments
Open

Support For DateOnly and TimeOnly #513

RHaughton opened this issue Jul 14, 2023 · 4 comments

Comments

@RHaughton
Copy link

Is there a plan to update this excellent library to support DateOnly and TimeOnly?

@RHaughton
Copy link
Author

bump

@xoofx
Copy link
Member

xoofx commented Sep 25, 2023

bump

I have no personal time/incentive to add such support, so if you want it, PR welcome. Before that, it would require maybe defining what exactly means "Support for DateOnly and TimeOnly" and how it relates to the existing support for dates.

@ranger-turtle
Copy link
Contributor

ranger-turtle commented Sep 25, 2023

@xoofx I consider implementing it now and I think I can achieve it copying the DateTimeFunctions.cs file twice for each type and replacing or removing right pieces of code (such as returning types). However, this way breaks the DRY principle. What do you think?

@xoofx
Copy link
Member

xoofx commented Sep 26, 2023

I can achieve it copying the DateTimeFunctions.cs file twice for each type and replacing or removing right pieces of code (such as returning types). However, this way breaks the DRY principle. What do you think?

I don't like the idea to copy DateTimeFunctions entirely. We have already a date object and it should cover all operations related to date/time.

I would think that existing methods can be adapted to work with both DateOnly/TimeOnly. It would require changing the signature of some methods like:

public static DateTime AddDays(DateTime date, double days)

would become

public static object AddDays(object date, double days)

and depending on whether date is a Datetime or a DateOnly it could return the proper type accordingly.

Similar solution for the others.

Ideally, it is better to not expose DateOnly/TimeOnly from the public API as it is only available in .NET 6+, and leave it as implementation/support details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants