2 @generated by mypy-protobuf. Do not edit manually!
6 import google.protobuf.descriptor
7 import google.protobuf.internal.well_known_types
8 import google.protobuf.message
9 import typing_extensions
11 DESCRIPTOR: google.protobuf.descriptor.FileDescriptor = ...
13 class Duration(google.protobuf.message.Message, google.protobuf.internal.well_known_types.Duration):
14 """A Duration represents a signed, fixed-length span of time represented
15 as a count of seconds and fractions of seconds at nanosecond
16 resolution. It is independent of any calendar and concepts like "day"
17 or "month". It is related to Timestamp in that the difference between
18 two Timestamp values is a Duration and it can be added or subtracted
19 from a Timestamp. Range is approximately +-10,000 years.
23 Example 1: Compute Duration from two Timestamps in pseudo code.
25 Timestamp start = ...;
27 Duration duration = ...;
29 duration.seconds = end.seconds - start.seconds;
30 duration.nanos = end.nanos - start.nanos;
32 if (duration.seconds < 0 && duration.nanos > 0) {
33 duration.seconds += 1;
34 duration.nanos -= 1000000000;
35 } else if (duration.seconds > 0 && duration.nanos < 0) {
36 duration.seconds -= 1;
37 duration.nanos += 1000000000;
40 Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
42 Timestamp start = ...;
43 Duration duration = ...;
46 end.seconds = start.seconds + duration.seconds;
47 end.nanos = start.nanos + duration.nanos;
51 end.nanos += 1000000000;
52 } else if (end.nanos >= 1000000000) {
54 end.nanos -= 1000000000;
57 Example 3: Compute Duration from datetime.timedelta in Python.
59 td = datetime.timedelta(days=3, minutes=10)
61 duration.FromTimedelta(td)
65 In JSON format, the Duration type is encoded as a string rather than an
66 object, where the string ends in the suffix "s" (indicating seconds) and
67 is preceded by the number of seconds, with nanoseconds expressed as
68 fractional seconds. For example, 3 seconds with 0 nanoseconds should be
69 encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
70 be expressed in JSON format as "3.000000001s", and 3 seconds and 1
71 microsecond should be expressed in JSON format as "3.000001s".
73 DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
74 SECONDS_FIELD_NUMBER: builtins.int
75 NANOS_FIELD_NUMBER: builtins.int
76 seconds: builtins.int = ...
77 """Signed seconds of the span of time. Must be from -315,576,000,000
78 to +315,576,000,000 inclusive. Note: these bounds are computed from:
79 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
82 nanos: builtins.int = ...
83 """Signed fractions of a second at nanosecond resolution of the span
84 of time. Durations less than one second are represented with a 0
85 `seconds` field and a positive or negative `nanos` field. For durations
86 of one second or more, a non-zero value for the `nanos` field must be
87 of the same sign as the `seconds` field. Must be from -999,999,999
88 to +999,999,999 inclusive.
93 seconds : builtins.int = ...,
94 nanos : builtins.int = ...,
96 def ClearField(self, field_name: typing_extensions.Literal["nanos",b"nanos","seconds",b"seconds"]) -> None: ...
97 global___Duration = Duration