Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/protobuf/src/google/protobuf/util/time_util.cc

Issue 2600753002: Reverts third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // give -3 as the result with the remainder being 1. This function ensures 135 // give -3 as the result with the remainder being 1. This function ensures
136 // we always return -2 (closer to zero) regardless of the implementation. 136 // we always return -2 (closer to zero) regardless of the implementation.
137 if (result < 0 && remainder > 0) { 137 if (result < 0 && remainder > 0) {
138 return result + 1; 138 return result + 1;
139 } else { 139 } else {
140 return result; 140 return result;
141 } 141 }
142 } 142 }
143 } // namespace 143 } // namespace
144 144
145 // Actually define these static const integers. Required by C++ standard (but
146 // some compilers don't like it).
147 #ifndef _MSC_VER
148 const int64 TimeUtil::kTimestampMinSeconds;
149 const int64 TimeUtil::kTimestampMaxSeconds;
150 const int64 TimeUtil::kDurationMaxSeconds;
151 const int64 TimeUtil::kDurationMinSeconds;
152 #endif // !_MSC_VER
153
154 string TimeUtil::ToString(const Timestamp& timestamp) { 145 string TimeUtil::ToString(const Timestamp& timestamp) {
155 return FormatTime(timestamp.seconds(), timestamp.nanos()); 146 return FormatTime(timestamp.seconds(), timestamp.nanos());
156 } 147 }
157 148
158 bool TimeUtil::FromString(const string& value, Timestamp* timestamp) { 149 bool TimeUtil::FromString(const string& value, Timestamp* timestamp) {
159 int64 seconds; 150 int64 seconds;
160 int32 nanos; 151 int32 nanos;
161 if (!ParseTime(value, &seconds, &nanos)) { 152 if (!ParseTime(value, &seconds, &nanos)) {
162 return false; 153 return false;
163 } 154 }
(...skipping 12 matching lines...) Expand all
176 167
177 string TimeUtil::ToString(const Duration& duration) { 168 string TimeUtil::ToString(const Duration& duration) {
178 string result; 169 string result;
179 int64 seconds = duration.seconds(); 170 int64 seconds = duration.seconds();
180 int32 nanos = duration.nanos(); 171 int32 nanos = duration.nanos();
181 if (seconds < 0 || nanos < 0) { 172 if (seconds < 0 || nanos < 0) {
182 result += "-"; 173 result += "-";
183 seconds = -seconds; 174 seconds = -seconds;
184 nanos = -nanos; 175 nanos = -nanos;
185 } 176 }
186 result += SimpleItoa(seconds); 177 result += StringPrintf("%" GOOGLE_LL_FORMAT "d", seconds);
187 if (nanos != 0) { 178 if (nanos != 0) {
188 result += "." + FormatNanos(nanos); 179 result += "." + FormatNanos(nanos);
189 } 180 }
190 result += "s"; 181 result += "s";
191 return result; 182 return result;
192 } 183 }
193 184
194 static int64 Pow(int64 x, int y) { 185 static int64 Pow(int64 x, int y) {
195 int64 result = 1; 186 int64 result = 1;
196 for (int i = 0; i < y; ++i) { 187 for (int i = 0; i < y; ++i) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 return t; 516 return t;
526 } 517 }
527 518
528 Duration operator-(const Timestamp& t1, const Timestamp& t2) { 519 Duration operator-(const Timestamp& t1, const Timestamp& t2) {
529 return CreateNormalized<Duration>(t1.seconds() - t2.seconds(), 520 return CreateNormalized<Duration>(t1.seconds() - t2.seconds(),
530 t1.nanos() - t2.nanos()); 521 t1.nanos() - t2.nanos());
531 } 522 }
532 } // namespace protobuf 523 } // namespace protobuf
533 524
534 } // namespace google 525 } // namespace google
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698