Skip to content

Commit

Permalink
nanosecond DateTime reader bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
gbirchmeier committed Mar 30, 2020
1 parent c07dd51 commit ba9d901
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion QuickFIXn/Fields/Converters/DateTimeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static System.DateTime ConvertToDateTime(string str, TimeStampPrecision p
try
{
//Avoid NanoString Path parsing if not possible from string length
if (str.Length > DATE_TIME_MAXLENGTH_WITHOUT_NANOSECONDS && precision == TimeStampPrecision.Nanosecond)
if (str.Length > DATE_TIME_MAXLENGTH_WITHOUT_NANOSECONDS)
{
return DateTimeFromNanoString(str);
}
Expand Down
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ What's New
* (patch) #383/#582 - Fix debug logfile name clash (chizz5056/gbirchmeier)
* (patch) #410/#583 - SocketAcceptPort now fully-obeyed (mvdtom)
* (minor) #585/#323 - Add Message.ToXML() (baffles/gbirchmeier)
* (patch) #591 - Nanosecond DateTime reader bugfix (gbirchmeier)

### v1.9.0:
* (minor) #469 - Add support for NET Standard 2.0 (jhickson)
Expand Down
10 changes: 10 additions & 0 deletions UnitTests/FieldMapTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ public void DateTimeFieldTest()
Assert.AreSame(r, tt);
}

[Test]
public void DateTimeFieldNanoTest()
{
fieldmap.SetField(new StringField(Tags.TransactTime, "20200309-20:53:10.643649215"));
TransactTime tt = new TransactTime();
fieldmap.GetField(tt);
// Ticks resolution is 100 nanoseconds, so we lose the last 2 decimal points
Assert.That(tt.Obj.Ticks, Is.EqualTo(637193839906436492));
}

[Test]
public void DateOnlyFieldTest()
{
Expand Down

0 comments on commit ba9d901

Please sign in to comment.