-
-
Notifications
You must be signed in to change notification settings - Fork 69
Trimming ten-thousandths of a second during TIMESPAN conversion to the DateTime in the NET Provider for Firebird. [DNET654] #611
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
Comments
Modified by: @cincuranetstatus: Open [ 1 ] => In Progress [ 3 ] |
Modified by: @cincuranetstatus: In Progress [ 3 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: vNext [ 10722 ] |
Commented by: Kamil Kocian (kociank) Thank you for your solution however the problem has not been solved completely yet. There is still a problem with a DateTime construction, where time precision is lost. Included list of afflicted methods : // Receiving data from Firebird // Sending data to Firebird |
Commented by: @cincuranet And of course the XdrStream.ReadDateTime. |
Commented by: @cincuranet What's wrong with these: private byte[] FirebirdSql.Data.Client.ExternalEngine.ExtArray.EncodeSlice(FirebirdSql.Data.Common.ArrayDesc, System.Array, int) These eventually call `DateTimeToTimeSpan` so only this one need fixing, no? |
Commented by: Kamil Kocian (kociank) Yes, exactly. Only "DateTimeToTimeSpan" need fixing. And sorry for XdrStream.ReadDateTime. |
Commented by: @cincuranet Do you mind writing tests for these? Probably somewhere in FbCommandTests. |
Commented by: Kamil Kocian (kociank) Sorry, I was without access to VS2015. Do you mean something like this (implemented in FbCommandTests) :
|
Submitted by: Kamil Kocian (kociank)
The NET Provider for Firebird trims ten-thousandths of a second during TIMESPAN conversion to the .NET DateTime type in method TypeDecoder.DecodeTime(int sql_time). Trimming the ten-thousandths of a second is causing problem when comparing time read from Firebird to .NET and using the value again in SQL statements.
However it is possible to initialize .NET type DateTime(or TimeSpan) with number of ticks, this way keeping the precision of Firebird TIMESTAMP in .NET.
Problematic source code in FirebirdSql.Data.FirebirdClient\Common\TypeDecoder.cs :
public static TimeSpan DecodeTime(int sql_time)
{
int millisInDay = sql_time / 10;
int hour = millisInDay / 3600000;
int minute = (millisInDay - hour * 3600000) / 60000;
int second = (millisInDay - hour * 3600000 - minute * 60000) / 1000;
int millisecond = millisInDay - hour * 3600000 - minute * 60000 - second * 1000;
}
Commits: a1e4f43 6fbf088 43bca52
The text was updated successfully, but these errors were encountered: