protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

TimeUtils::GetCurrentTime() and fractions of second

Open aafemt opened this issue 3 years ago • 3 comments

Version: 3.16 Language: C++ Linux GCC 7.2

I do "message.mutable_timestamp->CopyFrom(util::TimeUtil::GetCurrentTime());"

I expect resulting timestamp field to contain current time up to milliseconds at least because Linux has gettimeofday() supporting milliseconds. I see the time rounded to whole seconds.

In protobuf sources I see

void GetCurrentTime(int64* seconds, int32* nanos) {
  // TODO(xiaofeng): Improve the accuracy of this implementation (or just
  // remove this method from protobuf).
  *seconds = time(nullptr);
  *nanos = 0;
}

aafemt avatar Aug 30 '21 13:08 aafemt

xiaofeng was right. This method shouldn't be here. However now it is and we're stuck with it. I'm not sure if changing the behavior now is likely to break any clients or not.

elharo avatar Aug 30 '21 13:08 elharo

Could this be included in the documentation? Might avoid some confusion.

cyuanli avatar Jul 02 '22 15:07 cyuanli

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Feb 18 '24 10:02 github-actions[bot]

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

github-actions[bot] avatar Mar 03 '24 10:03 github-actions[bot]