You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all i want to thank you for your incredible library, which drastically improved my experience with Salesforce API, it is trully remarkable that you did it all on your own.
Previously i've already created an issue with DateTime UTC convertion, and figured my way around this problem, but currently i've faced it again and i'd like to propose a solution to solve it once and for all.
)
you're converting Salesforce Date to DateTime type, which, unfortunately leads to addition of the timezone, and therefore if my timezone is already in the next day and server's one is in the previous one, scenarios like this happens:
Info: Server time - yesterday, Local timezone - today
Get any entity with Date field (e.g. Date Of Birth) set to today, let's say 25.08.2023, it is automatically converted to local DateTime - 25.08.2023 00:00:00
Send it back without changing it at all, and while serialization happening - DateTime will automatically be converted to UTC, therefore date will go back (or forward) depending on a local timezone, which leads to dangerous sideeffects.
My proposal would be to convert Salesforce Date fields to DateOnly type, and will prevent any further issues like this one.
Potential breaking change: it would require ModelGenerator to be migrated to at least .NET 6. But i suppose it could be solved with preprocessor directives, for old .NET Core it could be left as is, for newer ones - as DateOnly.
Something like this
caseFieldType.date_sf:
#if NET6_0_OR_GREATER
type =typeof(DateOnly);
#elsetype=typeof(DateTime);
#endif
break;
I can create a pull request, to avoid taking your time, maybe there is some other drawbacks that i'm missing.
Thank you once again for your time and work!
The text was updated successfully, but these errors were encountered:
the Date type wasn't an option originally, but it looks like a good idea now. I'd like to maintain backwards compatibility a bit more, but I think that's manageable with the preprocessor directive and maybe a config flag or two. I'll dig into it, since that date issue is something that has annoyed me in my own production apps.
Hello Anthony,
First of all i want to thank you for your incredible library, which drastically improved my experience with Salesforce API, it is trully remarkable that you did it all on your own.
Previously i've already created an issue with DateTime UTC convertion, and figured my way around this problem, but currently i've faced it again and i'd like to propose a solution to solve it once and for all.
As i've read in the source code (
NetCoreForce/src/NetCoreForce.ModelGenerator/SfTypeConverter.cs
Line 30 in 54f5296
you're converting Salesforce Date to DateTime type, which, unfortunately leads to addition of the timezone, and therefore if my timezone is already in the next day and server's one is in the previous one, scenarios like this happens:
Info: Server time - yesterday, Local timezone - today
My proposal would be to convert Salesforce Date fields to DateOnly type, and will prevent any further issues like this one.
Potential breaking change: it would require ModelGenerator to be migrated to at least .NET 6. But i suppose it could be solved with preprocessor directives, for old .NET Core it could be left as is, for newer ones - as DateOnly.
Something like this
I can create a pull request, to avoid taking your time, maybe there is some other drawbacks that i'm missing.
Thank you once again for your time and work!
The text was updated successfully, but these errors were encountered: