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

DateTime.AddMilliseconds(and DateTime.AddMicroseconds ) #3449

Open
GLuca74 opened this issue Feb 1, 2025 · 5 comments
Open

DateTime.AddMilliseconds(and DateTime.AddMicroseconds ) #3449

GLuca74 opened this issue Feb 1, 2025 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@GLuca74
Copy link

GLuca74 commented Feb 1, 2025

Hello,

I am very new about PostgreSQL, I would like to ask you if there is a reason why you decided not to support DateTime.AddMilliseconds (and also DateTime.AddMicroseconds). In the class Npgsql.EntityFrameworkCore.PostgreSQL.Query.ExpressionTranslators.Internal.NpgsqlDateTimeMethodTranslator
I found

        { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddYears), [typeof(int)])!, "years" },
        { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMonths), [typeof(int)])!, "months" },
        { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddDays), [typeof(double)])!, "days" },
        { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddHours), [typeof(double)])!, "hours" },
        { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMinutes), [typeof(double)])!, "mins" },
        { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddSeconds), [typeof(double)])!, "secs" },
        **//{ typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMilliseconds), new[] { typeof(double) })!, "milliseconds" },**

AddMilliseconds is mentioned but has been commented out.

Thank you

@roji
Copy link
Member

roji commented Feb 1, 2025

I can't say I remember exactly at this point - back when I was originally implementing this, I remember running into some difficulties with the translation, possibly because sub-millisecond components are treated as fractional (floating point) and it was a bit complicated. Nobody has since actually needed that translation as far as I can remember.

@GLuca74
Copy link
Author

GLuca74 commented Feb 1, 2025

Hi @roji , I would like to try implementing it, I will probably fail but it will be a valuable experience. Honestly, this is the first time I attempt this kind of intervention, which repository would you recommend I clone?

@roji
Copy link
Member

roji commented Feb 2, 2025

which repository would you recommend I clone?

I'm not sure what you're asking here - this repository (where we're talking) is where the source code lives, and where you'll need to submit the PR. You can read some getting started tutorials for github and open source to understand the PR process better.

@roji roji added this to the Backlog milestone Feb 2, 2025
@roji roji added the enhancement New feature or request label Feb 2, 2025
@GLuca74
Copy link
Author

GLuca74 commented Feb 2, 2025

I apologize, I really expressed myself poorly. I meant which branch was better to start from. It seems that the main branch requires .Net10 and I would like to avoid getting tangled up with unofficial versions. The more correct question would have been if it's okay to start , for example, from the branch hotfix/9.0.4. I will still go read some tutorials.

Thank you

@roji
Copy link
Member

roji commented Feb 2, 2025

@GLuca74 the PR itself will have to be submitted against the main branch (for EF 10), as it's a new feature. You should simply be able to run restore.cmd (or restore.sh) at the repo root, that will download the correct SDK needed by EF, and then startvs.cmd should start VS using it - it should all be relatively painless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants