Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-1028

Pre-Epoch Dates Converted to Future Dates

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Major Change

      When inserting pre-epoch dates, all dates get converted to incorrect future dates on the database side.

      To reproduce from the shell:

      > date = new Date(1950, 1, 1);
      "Wed Feb 01 1950 00:00:00 GMT-0500 (EST)"

      > date.getTime();
      -628455600000

      > db.driver_test.insert(

      { "dob" : date }

      );

      > doc = db.driver_test.findOne();
      {
      "_id" : ObjectId("4bc88e3b65e31b7855e310a5"),
      "dob" : "Tue Jan -2147483647 584556000 14:25:52 GMT-0500 (EST)"
      }

      > doc.dob
      "Tue Jan -2147483647 584556000 14:25:52 GMT-0500 (EST)"

      > doc.dob.getTime();
      18446743445253951000

      > db.driver_test.find({ "dob" : { $lt : new Date() }});

      > db.driver_test.find({ "dob" : { $gt : new Date() }});

      { "_id" : ObjectId("4bc88e3b65e31b7855e310a5"), "dob" : "Tue Jan -2147483647 584556000 14:25:52 GMT-0500 (EST)" }

      mongoexport also exports a bad time:

      { "_id" :

      { "$oid" : "4bc88e3b65e31b7855e310a5" }

      , "dob" :

      { "$date" : 18446743445253951616 }

      }

      The current workaround that I can see if converting all times that we are going to store to longs and convert back and forth on the application side... This has a side effect of needing to do a large migration on our part.

            Assignee:
            kbanker Kyle Banker
            Reporter:
            durran Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: