OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 syntax = "proto3"; | 31 syntax = "proto3"; |
32 | 32 |
33 package google.protobuf; | 33 package google.protobuf; |
34 | 34 |
35 option csharp_namespace = "Google.Protobuf.WellKnownTypes"; | 35 option csharp_namespace = "Google.Protobuf.WellKnownTypes"; |
36 option cc_enable_arenas = true; | 36 option cc_enable_arenas = true; |
37 option go_package = "github.com/golang/protobuf/ptypes/timestamp"; | 37 option go_package = "github.com/golang/protobuf/ptypes/timestamp"; |
38 option java_package = "com.google.protobuf"; | 38 option java_package = "com.google.protobuf"; |
39 option java_outer_classname = "TimestampProto"; | 39 option java_outer_classname = "TimestampProto"; |
40 option java_multiple_files = true; | 40 option java_multiple_files = true; |
| 41 option java_generate_equals_and_hash = true; |
41 option objc_class_prefix = "GPB"; | 42 option objc_class_prefix = "GPB"; |
42 | 43 |
43 // A Timestamp represents a point in time independent of any time zone | 44 // A Timestamp represents a point in time independent of any time zone |
44 // or calendar, represented as seconds and fractions of seconds at | 45 // or calendar, represented as seconds and fractions of seconds at |
45 // nanosecond resolution in UTC Epoch time. It is encoded using the | 46 // nanosecond resolution in UTC Epoch time. It is encoded using the |
46 // Proleptic Gregorian Calendar which extends the Gregorian calendar | 47 // Proleptic Gregorian Calendar which extends the Gregorian calendar |
47 // backwards to year one. It is encoded assuming all minutes are 60 | 48 // backwards to year one. It is encoded assuming all minutes are 60 |
48 // seconds long, i.e. leap seconds are "smeared" so that no leap second | 49 // seconds long, i.e. leap seconds are "smeared" so that no leap second |
49 // table is needed for interpretation. Range is from | 50 // table is needed for interpretation. Range is from |
50 // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. | 51 // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. | 83 // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. |
83 // | 84 // |
84 // long millis = System.currentTimeMillis(); | 85 // long millis = System.currentTimeMillis(); |
85 // | 86 // |
86 // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) | 87 // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) |
87 // .setNanos((int) ((millis % 1000) * 1000000)).build(); | 88 // .setNanos((int) ((millis % 1000) * 1000000)).build(); |
88 // | 89 // |
89 // | 90 // |
90 // Example 5: Compute Timestamp from current time in Python. | 91 // Example 5: Compute Timestamp from current time in Python. |
91 // | 92 // |
92 // timestamp = Timestamp() | 93 // now = time.time() |
93 // timestamp.GetCurrentTime() | 94 // seconds = int(now) |
| 95 // nanos = int((now - seconds) * 10**9) |
| 96 // timestamp = Timestamp(seconds=seconds, nanos=nanos) |
94 // | 97 // |
95 // | 98 // |
96 message Timestamp { | 99 message Timestamp { |
97 | 100 |
98 // Represents seconds of UTC time since Unix epoch | 101 // Represents seconds of UTC time since Unix epoch |
99 // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to | 102 // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to |
100 // 9999-12-31T23:59:59Z inclusive. | 103 // 9999-12-31T23:59:59Z inclusive. |
101 int64 seconds = 1; | 104 int64 seconds = 1; |
102 | 105 |
103 // Non-negative fractions of a second at nanosecond resolution. Negative | 106 // Non-negative fractions of a second at nanosecond resolution. Negative |
104 // second values with fractions must still have non-negative nanos values | 107 // second values with fractions must still have non-negative nanos values |
105 // that count forward in time. Must be from 0 to 999,999,999 | 108 // that count forward in time. Must be from 0 to 999,999,999 |
106 // inclusive. | 109 // inclusive. |
107 int32 nanos = 2; | 110 int32 nanos = 2; |
108 } | 111 } |
OLD | NEW |