time_util.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
32 
39 
40 
41 
42 #include <google/protobuf/port_def.inc>
43 
44 namespace google {
45 namespace protobuf {
46 namespace util {
47 
50 
51 namespace {
52 static const int kNanosPerSecond = 1000000000;
53 static const int kMicrosPerSecond = 1000000;
54 static const int kMillisPerSecond = 1000;
55 static const int kNanosPerMillisecond = 1000000;
56 static const int kNanosPerMicrosecond = 1000;
57 static const int kSecondsPerMinute = 60; // Note that we ignore leap seconds.
58 static const int kSecondsPerHour = 3600;
59 
60 template <typename T>
61 T CreateNormalized(int64 seconds, int64 nanos);
62 
63 template <>
64 Timestamp CreateNormalized(int64 seconds, int64 nanos) {
65  // Make sure nanos is in the range.
66  if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {
67  seconds += nanos / kNanosPerSecond;
68  nanos = nanos % kNanosPerSecond;
69  }
70  // For Timestamp nanos should be in the range [0, 999999999]
71  if (nanos < 0) {
72  seconds -= 1;
73  nanos += kNanosPerSecond;
74  }
77  Timestamp result;
78  result.set_seconds(seconds);
79  result.set_nanos(static_cast<int32>(nanos));
80  return result;
81 }
82 
83 template <>
84 Duration CreateNormalized(int64 seconds, int64 nanos) {
85  // Make sure nanos is in the range.
86  if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {
87  seconds += nanos / kNanosPerSecond;
88  nanos = nanos % kNanosPerSecond;
89  }
90  // nanos should have the same sign as seconds.
91  if (seconds < 0 && nanos > 0) {
92  seconds += 1;
93  nanos -= kNanosPerSecond;
94  } else if (seconds > 0 && nanos < 0) {
95  seconds -= 1;
96  nanos += kNanosPerSecond;
97  }
100  Duration result;
101  result.set_seconds(seconds);
102  result.set_nanos(static_cast<int32>(nanos));
103  return result;
104 }
105 
106 // Format nanoseconds with either 3, 6, or 9 digits depending on the required
107 // precision to represent the exact value.
108 std::string FormatNanos(int32 nanos) {
109  if (nanos % kNanosPerMillisecond == 0) {
110  return StringPrintf("%03d", nanos / kNanosPerMillisecond);
111  } else if (nanos % kNanosPerMicrosecond == 0) {
112  return StringPrintf("%06d", nanos / kNanosPerMicrosecond);
113  } else {
114  return StringPrintf("%09d", nanos);
115  }
116 }
117 
118 std::string FormatTime(int64 seconds, int32 nanos) {
120 }
121 
122 bool ParseTime(const std::string& value, int64* seconds, int32* nanos) {
124 }
125 
126 void CurrentTime(int64* seconds, int32* nanos) {
128 }
129 
130 // Truncates the remainder part after division.
131 int64 RoundTowardZero(int64 value, int64 divider) {
132  int64 result = value / divider;
133  int64 remainder = value % divider;
134  // Before C++11, the sign of the remainder is implementation dependent if
135  // any of the operands is negative. Here we try to enforce C++11's "rounded
136  // toward zero" semantics. For example, for (-5) / 2 an implementation may
137  // give -3 as the result with the remainder being 1. This function ensures
138  // we always return -2 (closer to zero) regardless of the implementation.
139  if (result < 0 && remainder > 0) {
140  return result + 1;
141  } else {
142  return result;
143  }
144 }
145 } // namespace
146 
147 // Actually define these static const integers. Required by C++ standard (but
148 // some compilers don't like it).
149 #ifndef _MSC_VER
154 #endif // !_MSC_VER
155 
157  return FormatTime(timestamp.seconds(), timestamp.nanos());
158 }
159 
161  int64 seconds;
162  int32 nanos;
163  if (!ParseTime(value, &seconds, &nanos)) {
164  return false;
165  }
166  *timestamp = CreateNormalized<Timestamp>(seconds, nanos);
167  return true;
168 }
169 
171  int64 seconds;
172  int32 nanos;
173  CurrentTime(&seconds, &nanos);
174  return CreateNormalized<Timestamp>(seconds, nanos);
175 }
176 
178 
179 std::string TimeUtil::ToString(const Duration& duration) {
180  std::string result;
181  int64 seconds = duration.seconds();
182  int32 nanos = duration.nanos();
183  if (seconds < 0 || nanos < 0) {
184  result += "-";
185  seconds = -seconds;
186  nanos = -nanos;
187  }
188  result += StrCat(seconds);
189  if (nanos != 0) {
190  result += "." + FormatNanos(nanos);
191  }
192  result += "s";
193  return result;
194 }
195 
196 static int64 Pow(int64 x, int y) {
197  int64 result = 1;
198  for (int i = 0; i < y; ++i) {
199  result *= x;
200  }
201  return result;
202 }
203 
204 bool TimeUtil::FromString(const std::string& value, Duration* duration) {
205  if (value.length() <= 1 || value[value.length() - 1] != 's') {
206  return false;
207  }
208  bool negative = (value[0] == '-');
209  int sign_length = (negative ? 1 : 0);
210  // Parse the duration value as two integers rather than a float value
211  // to avoid precision loss.
212  std::string seconds_part, nanos_part;
213  size_t pos = value.find_last_of(".");
214  if (pos == std::string::npos) {
215  seconds_part = value.substr(sign_length, value.length() - 1 - sign_length);
216  nanos_part = "0";
217  } else {
218  seconds_part = value.substr(sign_length, pos - sign_length);
219  nanos_part = value.substr(pos + 1, value.length() - pos - 2);
220  }
221  char* end;
222  int64 seconds = strto64(seconds_part.c_str(), &end, 10);
223  if (end != seconds_part.c_str() + seconds_part.length()) {
224  return false;
225  }
226  int64 nanos = strto64(nanos_part.c_str(), &end, 10);
227  if (end != nanos_part.c_str() + nanos_part.length()) {
228  return false;
229  }
230  nanos = nanos * Pow(10, 9 - nanos_part.length());
231  if (negative) {
232  // If a Duration is negative, both seconds and nanos should be negative.
233  seconds = -seconds;
234  nanos = -nanos;
235  }
236  duration->set_seconds(seconds);
237  duration->set_nanos(static_cast<int32>(nanos));
238  return true;
239 }
240 
242  return CreateNormalized<Duration>(nanos / kNanosPerSecond,
243  nanos % kNanosPerSecond);
244 }
245 
247  return CreateNormalized<Duration>(
248  micros / kMicrosPerSecond,
249  (micros % kMicrosPerSecond) * kNanosPerMicrosecond);
250 }
251 
253  return CreateNormalized<Duration>(
254  millis / kMillisPerSecond,
255  (millis % kMillisPerSecond) * kNanosPerMillisecond);
256 }
257 
259  return CreateNormalized<Duration>(seconds, 0);
260 }
261 
263  return CreateNormalized<Duration>(minutes * kSecondsPerMinute, 0);
264 }
265 
267  return CreateNormalized<Duration>(hours * kSecondsPerHour, 0);
268 }
269 
271  return duration.seconds() * kNanosPerSecond + duration.nanos();
272 }
273 
275  return duration.seconds() * kMicrosPerSecond +
276  RoundTowardZero(duration.nanos(), kNanosPerMicrosecond);
277 }
278 
280  return duration.seconds() * kMillisPerSecond +
281  RoundTowardZero(duration.nanos(), kNanosPerMillisecond);
282 }
283 
285  return duration.seconds();
286 }
287 
289  return RoundTowardZero(duration.seconds(), kSecondsPerMinute);
290 }
291 
293  return RoundTowardZero(duration.seconds(), kSecondsPerHour);
294 }
295 
297  return CreateNormalized<Timestamp>(nanos / kNanosPerSecond,
298  nanos % kNanosPerSecond);
299 }
300 
302  return CreateNormalized<Timestamp>(
303  micros / kMicrosPerSecond,
304  micros % kMicrosPerSecond * kNanosPerMicrosecond);
305 }
306 
308  return CreateNormalized<Timestamp>(
309  millis / kMillisPerSecond,
310  millis % kMillisPerSecond * kNanosPerMillisecond);
311 }
312 
314  return CreateNormalized<Timestamp>(seconds, 0);
315 }
316 
318  return timestamp.seconds() * kNanosPerSecond + timestamp.nanos();
319 }
320 
322  return timestamp.seconds() * kMicrosPerSecond +
323  RoundTowardZero(timestamp.nanos(), kNanosPerMicrosecond);
324 }
325 
327  return timestamp.seconds() * kMillisPerSecond +
328  RoundTowardZero(timestamp.nanos(), kNanosPerMillisecond);
329 }
330 
332  return timestamp.seconds();
333 }
334 
336  return CreateNormalized<Timestamp>(static_cast<int64>(value), 0);
337 }
338 
340  return static_cast<time_t>(value.seconds());
341 }
342 
344  return CreateNormalized<Timestamp>(value.tv_sec,
345  value.tv_usec * kNanosPerMicrosecond);
346 }
347 
349  timeval result;
350  result.tv_sec = value.seconds();
351  result.tv_usec = RoundTowardZero(value.nanos(), kNanosPerMicrosecond);
352  return result;
353 }
354 
356  return CreateNormalized<Duration>(value.tv_sec,
357  value.tv_usec * kNanosPerMicrosecond);
358 }
359 
361  timeval result;
362  result.tv_sec = value.seconds();
363  result.tv_usec = RoundTowardZero(value.nanos(), kNanosPerMicrosecond);
364  // timeval.tv_usec's range is [0, 1000000)
365  if (result.tv_usec < 0) {
366  result.tv_sec -= 1;
367  result.tv_usec += kMicrosPerSecond;
368  }
369  return result;
370 }
371 
372 } // namespace util
373 } // namespace protobuf
374 } // namespace google
375 
376 namespace google {
377 namespace protobuf {
378 namespace {
379 using ::PROTOBUF_NAMESPACE_ID::util::CreateNormalized;
381 
382 // Convert a Duration to uint128.
383 void ToUint128(const Duration& value, uint128* result, bool* negative) {
384  if (value.seconds() < 0 || value.nanos() < 0) {
385  *negative = true;
386  *result = static_cast<uint64>(-value.seconds());
387  *result = *result * kNanosPerSecond + static_cast<uint32>(-value.nanos());
388  } else {
389  *negative = false;
390  *result = static_cast<uint64>(value.seconds());
391  *result = *result * kNanosPerSecond + static_cast<uint32>(value.nanos());
392  }
393 }
394 
395 void ToDuration(const uint128& value, bool negative, Duration* duration) {
396  int64 seconds =
397  static_cast<int64>(Uint128Low64(value / kNanosPerSecond));
398  int32 nanos = static_cast<int32>(Uint128Low64(value % kNanosPerSecond));
399  if (negative) {
400  seconds = -seconds;
401  nanos = -nanos;
402  }
403  duration->set_seconds(seconds);
404  duration->set_nanos(nanos);
405 }
406 } // namespace
407 
409  d1 = CreateNormalized<Duration>(d1.seconds() + d2.seconds(),
410  d1.nanos() + d2.nanos());
411  return d1;
412 }
413 
414 Duration& operator-=(Duration& d1, const Duration& d2) { // NOLINT
415  d1 = CreateNormalized<Duration>(d1.seconds() - d2.seconds(),
416  d1.nanos() - d2.nanos());
417  return d1;
418 }
419 
420 Duration& operator*=(Duration& d, int64 r) { // NOLINT
421  bool negative;
422  uint128 value;
423  ToUint128(d, &value, &negative);
424  if (r > 0) {
425  value *= static_cast<uint64>(r);
426  } else {
427  negative = !negative;
428  value *= static_cast<uint64>(-r);
429  }
430  ToDuration(value, negative, &d);
431  return d;
432 }
433 
434 Duration& operator*=(Duration& d, double r) { // NOLINT
435  double result = (d.seconds() * 1.0 + 1.0 * d.nanos() / kNanosPerSecond) * r;
436  int64 seconds = static_cast<int64>(result);
437  int32 nanos = static_cast<int32>((result - seconds) * kNanosPerSecond);
438  // Note that we normalize here not just because nanos can have a different
439  // sign from seconds but also that nanos can be any arbitrary value when
440  // overflow happens (i.e., the result is a much larger value than what
441  // int64 can represent).
442  d = CreateNormalized<Duration>(seconds, nanos);
443  return d;
444 }
445 
446 Duration& operator/=(Duration& d, int64 r) { // NOLINT
447  bool negative;
448  uint128 value;
449  ToUint128(d, &value, &negative);
450  if (r > 0) {
451  value /= static_cast<uint64>(r);
452  } else {
453  negative = !negative;
454  value /= static_cast<uint64>(-r);
455  }
456  ToDuration(value, negative, &d);
457  return d;
458 }
459 
460 Duration& operator/=(Duration& d, double r) { // NOLINT
461  return d *= 1.0 / r;
462 }
463 
464 Duration& operator%=(Duration& d1, const Duration& d2) { // NOLINT
465  bool negative1, negative2;
466  uint128 value1, value2;
467  ToUint128(d1, &value1, &negative1);
468  ToUint128(d2, &value2, &negative2);
469  uint128 result = value1 % value2;
470  // When negative values are involved in division, we round the division
471  // result towards zero. With this semantics, sign of the remainder is the
472  // same as the dividend. For example:
473  // -5 / 10 = 0, -5 % 10 = -5
474  // -5 / (-10) = 0, -5 % (-10) = -5
475  // 5 / (-10) = 0, 5 % (-10) = 5
476  ToDuration(result, negative1, &d1);
477  return d1;
478 }
479 
480 int64 operator/(const Duration& d1, const Duration& d2) {
481  bool negative1, negative2;
482  uint128 value1, value2;
483  ToUint128(d1, &value1, &negative1);
484  ToUint128(d2, &value2, &negative2);
485  int64 result = Uint128Low64(value1 / value2);
486  if (negative1 != negative2) {
487  result = -result;
488  }
489  return result;
490 }
491 
492 Timestamp& operator+=(Timestamp& t, const Duration& d) { // NOLINT
493  t = CreateNormalized<Timestamp>(t.seconds() + d.seconds(),
494  t.nanos() + d.nanos());
495  return t;
496 }
497 
498 Timestamp& operator-=(Timestamp& t, const Duration& d) { // NOLINT
499  t = CreateNormalized<Timestamp>(t.seconds() - d.seconds(),
500  t.nanos() - d.nanos());
501  return t;
502 }
503 
504 Duration operator-(const Timestamp& t1, const Timestamp& t2) {
505  return CreateNormalized<Duration>(t1.seconds() - t2.seconds(),
506  t1.nanos() - t2.nanos());
507 }
508 } // namespace protobuf
509 } // namespace google
google::protobuf::util::TimeUtil::MicrosecondsToDuration
static Duration MicrosecondsToDuration(int64 micros)
Definition: time_util.cc:246
google::protobuf::value
const Descriptor::ReservedRange value
Definition: src/google/protobuf/descriptor.h:1954
google::protobuf::Uint128Low64
uint64 Uint128Low64(const uint128 &v)
Definition: int128.h:130
end
GLuint GLuint end
Definition: glcorearb.h:2858
google::protobuf::operator%=
Duration & operator%=(Duration &d1, const Duration &d2)
Definition: time_util.cc:464
Timestamp
Definition: timestamp.pb.h:69
google::protobuf::int64
int64_t int64
Definition: protobuf/src/google/protobuf/stubs/port.h:151
google::protobuf::StrCat
string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: strutil.cc:1480
Duration::set_seconds
void set_seconds(::PROTOBUF_NAMESPACE_ID::int64 value)
Definition: duration.pb.h:247
google::protobuf::strto64
int64 strto64(const char *nptr, char **endptr, int base)
Definition: strutil.h:374
google::protobuf::util::TimeUtil::GetEpoch
static Timestamp GetEpoch()
Definition: time_util.cc:177
GOOGLE_DCHECK
#define GOOGLE_DCHECK
Definition: logging.h:194
google::protobuf::util::TimeUtil::TimevalToTimestamp
static Timestamp TimevalToTimestamp(const timeval &value)
Definition: time_util.cc:343
google::protobuf::operator+=
Duration & operator+=(Duration &d1, const Duration &d2)
Definition: time_util.cc:408
google::protobuf::util::TimeUtil::kDurationMinSeconds
static const int64 kDurationMinSeconds
Definition: time_util.h:73
google::protobuf::util::TimeUtil::kDurationMaxSeconds
static const int64 kDurationMaxSeconds
Definition: time_util.h:74
google::protobuf::uint32
uint32_t uint32
Definition: protobuf/src/google/protobuf/stubs/port.h:155
google::protobuf::util::TimeUtil::DurationToMilliseconds
static int64 DurationToMilliseconds(const Duration &duration)
Definition: time_util.cc:279
google::protobuf::util::TimeUtil::GetCurrentTime
static Timestamp GetCurrentTime()
Definition: time_util.cc:170
google::protobuf::util::TimeUtil::TimestampToMilliseconds
static int64 TimestampToMilliseconds(const Timestamp &timestamp)
Definition: time_util.cc:326
duration.pb.h
google::protobuf::operator/
uint128 operator/(const uint128 &lhs, const uint128 &rhs)
Definition: int128.h:312
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
y
GLint y
Definition: glcorearb.h:2768
google::protobuf::util::TimeUtil::DurationToMinutes
static int64 DurationToMinutes(const Duration &duration)
Definition: time_util.cc:288
x
GLint GLenum GLint x
Definition: glcorearb.h:2834
google::protobuf::util::TimeUtil::Timestamp
google::protobuf::Timestamp Timestamp
Definition: time_util.h:63
google::protobuf::operator-
uint128 operator-(const uint128 &val)
Definition: int128.h:185
T
#define T(upbtypeconst, upbtype, ctype, default_value)
google::protobuf::util::TimeUtil::DurationToTimeval
static timeval DurationToTimeval(const Duration &value)
Definition: time_util.cc:360
google::protobuf::util::TimeUtil::kTimestampMinSeconds
static const int64 kTimestampMinSeconds
Definition: time_util.h:70
Duration::nanos
::PROTOBUF_NAMESPACE_ID::int32 nanos() const
Definition: duration.pb.h:257
google::protobuf::util::TimeUtil::DurationToSeconds
static int64 DurationToSeconds(const Duration &duration)
Definition: time_util.cc:284
Timestamp
struct Timestamp Timestamp
Definition: php/ext/google/protobuf/protobuf.h:663
google::protobuf::int32
int32_t int32
Definition: protobuf/src/google/protobuf/stubs/port.h:150
google::protobuf::util::TimeUtil::TimestampToSeconds
static int64 TimestampToSeconds(const Timestamp &timestamp)
Definition: time_util.cc:331
google::protobuf::util::TimeUtil::TimestampToTimeT
static time_t TimestampToTimeT(const Timestamp &value)
Definition: time_util.cc:339
google::protobuf.internal::GetCurrentTime
void GetCurrentTime(int64 *seconds, int32 *nanos)
Definition: time.cc:264
Timestamp::set_seconds
void set_seconds(::PROTOBUF_NAMESPACE_ID::int64 value)
Definition: timestamp.pb.h:247
strutil.h
google::protobuf::util::TimeUtil::FromString
static bool FromString(const std::string &value, Timestamp *timestamp)
Definition: time_util.cc:160
int128.h
google::protobuf::util::TimeUtil::MinutesToDuration
static Duration MinutesToDuration(int64 minutes)
Definition: time_util.cc:262
google::protobuf::util::TimeUtil::kTimestampMaxSeconds
static const int64 kTimestampMaxSeconds
Definition: time_util.h:72
google::protobuf::util::TimeUtil::TimevalToDuration
static Duration TimevalToDuration(const timeval &value)
Definition: time_util.cc:355
time.h
google::protobuf::util::Pow
static int64 Pow(int64 x, int y)
Definition: time_util.cc:196
google::protobuf::uint64
uint64_t uint64
Definition: protobuf/src/google/protobuf/stubs/port.h:156
google::protobuf::util::TimeUtil::DurationToNanoseconds
static int64 DurationToNanoseconds(const Duration &duration)
Definition: time_util.cc:270
Timestamp::nanos
::PROTOBUF_NAMESPACE_ID::int32 nanos() const
Definition: timestamp.pb.h:257
google::protobuf::util::TimeUtil::TimestampToTimeval
static timeval TimestampToTimeval(const Timestamp &value)
Definition: time_util.cc:348
google::protobuf::util::TimeUtil::HoursToDuration
static Duration HoursToDuration(int64 hours)
Definition: time_util.cc:266
google::protobuf.internal::ParseTime
bool ParseTime(const string &value, int64 *seconds, int32 *nanos)
Definition: time.cc:285
d
d
google::protobuf::StringPrintf
string StringPrintf(const char *format,...)
Definition: stringprintf.cc:109
google::protobuf::util::TimeUtil::NanosecondsToTimestamp
static Timestamp NanosecondsToTimestamp(int64 nanos)
Definition: time_util.cc:296
google::protobuf::util::TimeUtil::TimestampToMicroseconds
static int64 TimestampToMicroseconds(const Timestamp &timestamp)
Definition: time_util.cc:321
google::protobuf::util::TimeUtil::MillisecondsToDuration
static Duration MillisecondsToDuration(int64 millis)
Definition: time_util.cc:252
Timestamp::seconds
::PROTOBUF_NAMESPACE_ID::int64 seconds() const
Definition: timestamp.pb.h:243
google::protobuf::util::TimeUtil::DurationToMicroseconds
static int64 DurationToMicroseconds(const Duration &duration)
Definition: time_util.cc:274
google::protobuf::util::TimeUtil::NanosecondsToDuration
static Duration NanosecondsToDuration(int64 nanos)
Definition: time_util.cc:241
i
int i
Definition: gmock-matchers_test.cc:764
google::protobuf::operator/=
Duration & operator/=(Duration &d, int64 r)
Definition: time_util.cc:446
google::protobuf::uint128
Definition: int128.h:53
google::protobuf::util::TimeUtil::MicrosecondsToTimestamp
static Timestamp MicrosecondsToTimestamp(int64 micros)
Definition: time_util.cc:301
Duration
struct Duration Duration
Definition: php/ext/google/protobuf/protobuf.h:631
time_util.h
Timestamp::set_nanos
void set_nanos(::PROTOBUF_NAMESPACE_ID::int32 value)
Definition: timestamp.pb.h:261
stringprintf.h
r
GLboolean r
Definition: glcorearb.h:3228
google::protobuf::util::TimeUtil::MillisecondsToTimestamp
static Timestamp MillisecondsToTimestamp(int64 millis)
Definition: time_util.cc:307
google::protobuf.internal::FormatTime
string FormatTime(int64 seconds, int32 nanos)
Definition: time.cc:271
google::protobuf::operator*=
Duration & operator*=(Duration &d, int64 r)
Definition: time_util.cc:420
Duration::seconds
::PROTOBUF_NAMESPACE_ID::int64 seconds() const
Definition: duration.pb.h:243
google::protobuf::util::converter::kNanosPerSecond
const int32 kNanosPerSecond
Definition: constants.h:65
google::protobuf::util::TimeUtil::ToString
static std::string ToString(const Timestamp &timestamp)
Definition: time_util.cc:156
Duration
Definition: duration.pb.h:69
Duration::set_nanos
void set_nanos(::PROTOBUF_NAMESPACE_ID::int32 value)
Definition: duration.pb.h:261
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
google::protobuf::util::TimeUtil::SecondsToDuration
static Duration SecondsToDuration(int64 seconds)
Definition: time_util.cc:258
google::protobuf::util::TimeUtil::DurationToHours
static int64 DurationToHours(const Duration &duration)
Definition: time_util.cc:292
timestamp.pb.h
google
Definition: data_proto2_to_proto3_util.h:11
google::protobuf::operator-=
Duration & operator-=(Duration &d1, const Duration &d2)
Definition: time_util.cc:414
google::protobuf::util::TimeUtil::SecondsToTimestamp
static Timestamp SecondsToTimestamp(int64 seconds)
Definition: time_util.cc:313
google::protobuf::util::TimeUtil::TimeTToTimestamp
static Timestamp TimeTToTimestamp(time_t value)
Definition: time_util.cc:335
google::protobuf::util::TimeUtil::TimestampToNanoseconds
static int64 TimestampToNanoseconds(const Timestamp &timestamp)
Definition: time_util.cc:317


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:00