diff options
Diffstat (limited to 'src/mongo/bson/json.cpp')
-rw-r--r-- | src/mongo/bson/json.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mongo/bson/json.cpp b/src/mongo/bson/json.cpp index 2b13e318e44..3bf5c531cd0 100644 --- a/src/mongo/bson/json.cpp +++ b/src/mongo/bson/json.cpp @@ -471,12 +471,12 @@ namespace mongo { if (!ret.isOK()) { return ret; } - date = numberLong; + date = Date_t::fromMillisSinceEpoch(numberLong); } else { // SERVER-11920: We should use parseNumberFromString here, but that function requires // that we know ahead of time where the number ends, which is not currently the case. - date = static_cast<unsigned long long>(strtoll(_input, &endptr, 10)); + date = Date_t::fromMillisSinceEpoch(strtoll(_input, &endptr, 10)); if (_input == endptr) { return parseError("Date expecting integer milliseconds"); } @@ -487,7 +487,8 @@ namespace mongo { // SERVER-11920: We should use parseNumberFromString here, but that function // requires that we know ahead of time where the number ends, which is not currently // the case. - date = strtoull(_input, &endptr, 10); + date = Date_t::fromMillisSinceEpoch( + static_cast<long long>(strtoull(_input, &endptr, 10))); if (errno == ERANGE) { return parseError("Date milliseconds overflow"); } @@ -753,7 +754,7 @@ namespace mongo { char* endptr; // SERVER-11920: We should use parseNumberFromString here, but that function requires that // we know ahead of time where the number ends, which is not currently the case. - Date_t date = static_cast<unsigned long long>(strtoll(_input, &endptr, 10)); + Date_t date = Date_t::fromMillisSinceEpoch(strtoll(_input, &endptr, 10)); if (_input == endptr) { return parseError("Date expecting integer milliseconds"); } @@ -763,7 +764,8 @@ namespace mongo { errno = 0; // SERVER-11920: We should use parseNumberFromString here, but that function requires // that we know ahead of time where the number ends, which is not currently the case. - date = strtoull(_input, &endptr, 10); + date = Date_t::fromMillisSinceEpoch( + static_cast<long long>(strtoull(_input, &endptr, 10))); if (errno == ERANGE) { return parseError("Date milliseconds overflow"); } |