Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About type of time #169

Closed
alanyangbo opened this issue Jan 17, 2015 · 1 comment
Closed

About type of time #169

alanyangbo opened this issue Jan 17, 2015 · 1 comment

Comments

@alanyangbo
Copy link

Addition of a small set of standard types for representation of time.Who can do an example?

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Jan 20, 2015

We'll include two standard protos in protobuf runtime:
// file: google/protobuf/timestamp.proto
syntax = "proto3";
package google.protobuf;
message Timestamp {
int64 seconds = 1;
int32 nanos = 2;
}

// file: google/protobuf/duration.proto
syntax = "proto3";
package google.protobuf;
message Duration {
int64 seconds = 1;
int32 nanos = 2;
}

So in your .proto file, you can use these types to define fields:
message MyMessage {
optional Timestamp snapshot_time = 1;
}

Different programming languages will use their own native representation for these types in the generated code. For languages that haven't support these types yet, they can just generate these as normal message fields.

@xfxyjwf xfxyjwf closed this as completed Jan 20, 2016
yordis pushed a commit to yordis/protobuf that referenced this issue Dec 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…#169)

Previously when decoding varints, the value was not correctly decoded
from wire format to protobuf format. Consequently when signed ints which
are encoded on the wire using ZigZag format, the values returned are not
correct. This commit updates the decoder to ensure all values are
transformed from wire format to protobuf format, and includes a couple
of unit tests to validate the expected behaviour.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants