Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-114

DateTime data types are off by a few ticks

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 0.7
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Win Server 2008.
      .NET 3.5

      Create a date, save it, retrieve it back and the DateTime.CompareTo() function says that they are not equal. All inner fields are equal except for the Ticks field.

      Not sure if it matters, but doing everything in SafeMode, and the date property is decorated with [BsonDateTimeOptions(Kind = DateTimeKind.Local)].

      Steps to reproduce:
      -------------------------------

      var myItem = new Item(...);

      var myDate = DateTime.Now;
      myItem.date = myDate;

      // this assert is passes.
      Assert.AreEqual(0, myDate.CompareTo(myItem.date));

      myCollection<Item>.Save(myItem, SafeMode.True);

      // query the db to get the same object that is myItem.
      var savedAndRetrievedMyItem = myCollection.FindOneAs(...);

      // this assert fails.
      Assert.AreEqual(0, myDate.CompareTo(savedAndRetrievedMyItem.date));

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            sym3tri Ed Rooth
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: