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

DateTime data types are off by a few ticks

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 0.7
    • None
    • None
    • None
    • Win Server 2008.
      .NET 3.5

    Description

      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));

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: