summaryrefslogtreecommitdiff
path: root/src/mongo/bson/json.cpp
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-05-07 16:45:29 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-05-12 09:57:33 -0400
commit9aac625685811873ffbc2d3e8d09531eff1ce10e (patch)
treeecd8dd9fc9d148b196c6ab2aa5e38e5f9e327c54 /src/mongo/bson/json.cpp
parent21a16d229bdba571f1118a419898b666c666b869 (diff)
downloadmongo-9aac625685811873ffbc2d3e8d09531eff1ce10e.tar.gz
SERVER-13874 Make mongo::Milliseconds et al. aliases for equivalent stdx::chrono types.
Also introduces operators for adding stdx::chrono::duration to Date_t, subtracting two Date_ts to get Milliseconds, and remove the use of reinterpret_cast from the implementation of BSON Timestamp type.
Diffstat (limited to 'src/mongo/bson/json.cpp')
-rw-r--r--src/mongo/bson/json.cpp12
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");
}