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 15 matching lines...) Expand all Loading... |
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
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; | |
37 option go_package = "github.com/golang/protobuf/ptypes/duration"; | 36 option go_package = "github.com/golang/protobuf/ptypes/duration"; |
38 option java_package = "com.google.protobuf"; | 37 option java_package = "com.google.protobuf"; |
39 option java_outer_classname = "DurationProto"; | 38 option java_outer_classname = "DurationProto"; |
40 option java_multiple_files = true; | 39 option java_multiple_files = true; |
| 40 option java_generate_equals_and_hash = true; |
41 option objc_class_prefix = "GPB"; | 41 option objc_class_prefix = "GPB"; |
42 | 42 |
43 // A Duration represents a signed, fixed-length span of time represented | 43 // A Duration represents a signed, fixed-length span of time represented |
44 // as a count of seconds and fractions of seconds at nanosecond | 44 // as a count of seconds and fractions of seconds at nanosecond |
45 // resolution. It is independent of any calendar and concepts like "day" | 45 // resolution. It is independent of any calendar and concepts like "day" |
46 // or "month". It is related to Timestamp in that the difference between | 46 // or "month". It is related to Timestamp in that the difference between |
47 // two Timestamp values is a Duration and it can be added or subtracted | 47 // two Timestamp values is a Duration and it can be added or subtracted |
48 // from a Timestamp. Range is approximately +-10,000 years. | 48 // from a Timestamp. Range is approximately +-10,000 years. |
49 // | 49 // |
50 // Example 1: Compute Duration from two Timestamps in pseudo code. | 50 // Example 1: Compute Duration from two Timestamps in pseudo code. |
(...skipping 23 matching lines...) Expand all Loading... |
74 // end.nanos = start.nanos + duration.nanos; | 74 // end.nanos = start.nanos + duration.nanos; |
75 // | 75 // |
76 // if (end.nanos < 0) { | 76 // if (end.nanos < 0) { |
77 // end.seconds -= 1; | 77 // end.seconds -= 1; |
78 // end.nanos += 1000000000; | 78 // end.nanos += 1000000000; |
79 // } else if (end.nanos >= 1000000000) { | 79 // } else if (end.nanos >= 1000000000) { |
80 // end.seconds += 1; | 80 // end.seconds += 1; |
81 // end.nanos -= 1000000000; | 81 // end.nanos -= 1000000000; |
82 // } | 82 // } |
83 // | 83 // |
84 // Example 3: Compute Duration from datetime.timedelta in Python. | |
85 // | |
86 // td = datetime.timedelta(days=3, minutes=10) | |
87 // duration = Duration() | |
88 // duration.FromTimedelta(td) | |
89 // | |
90 // | 84 // |
91 message Duration { | 85 message Duration { |
92 | 86 |
93 // Signed seconds of the span of time. Must be from -315,576,000,000 | 87 // Signed seconds of the span of time. Must be from -315,576,000,000 |
94 // to +315,576,000,000 inclusive. | 88 // to +315,576,000,000 inclusive. |
95 int64 seconds = 1; | 89 int64 seconds = 1; |
96 | 90 |
97 // Signed fractions of a second at nanosecond resolution of the span | 91 // Signed fractions of a second at nanosecond resolution of the span |
98 // of time. Durations less than one second are represented with a 0 | 92 // of time. Durations less than one second are represented with a 0 |
99 // `seconds` field and a positive or negative `nanos` field. For durations | 93 // `seconds` field and a positive or negative `nanos` field. For durations |
100 // of one second or more, a non-zero value for the `nanos` field must be | 94 // of one second or more, a non-zero value for the `nanos` field must be |
101 // of the same sign as the `seconds` field. Must be from -999,999,999 | 95 // of the same sign as the `seconds` field. Must be from -999,999,999 |
102 // to +999,999,999 inclusive. | 96 // to +999,999,999 inclusive. |
103 int32 nanos = 2; | 97 int32 nanos = 2; |
104 } | 98 } |
OLD | NEW |