1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
use BTreeMap;
use String;
use Vec;
use ;
/// A Duration represents a signed, fixed-length span of time represented as a count of seconds and
/// fractions of seconds at nanosecond resolution. It is independent of any calendar and concepts
/// like "day" or "month". It is related to Timestamp in that the difference between two Timestamp
/// values is a Duration.
///
/// Values of this type are not guaranteed to only exist in their normalized form.
///
/// # Examples
///
/// Example 1: Compute Duration from two Timestamps in pseudo code.
///
/// ```text
/// Timestamp start = ...;
/// Timestamp end = ...;
/// Duration duration = ...;
///
/// duration.seconds = end.seconds - start.seconds;
/// duration.nanos = end.nanos - start.nanos;
///
/// if (duration.seconds < 0 && duration.nanos > 0) {
/// duration.seconds += 1;
/// duration.nanos -= 1000000000;
/// } else if (duration.seconds > 0 && duration.nanos < 0) {
/// duration.seconds -= 1;
/// duration.nanos += 1000000000;
/// }
/// ```
///
/// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
///
/// ```text
/// Timestamp start = ...;
/// Duration duration = ...;
/// Timestamp end = ...;
///
/// end.seconds = start.seconds + duration.seconds;
/// end.nanos = start.nanos + duration.nanos;
///
/// if (end.nanos < 0) {
/// end.seconds -= 1;
/// end.nanos += 1000000000;
/// } else if (end.nanos >= 1000000000) {
/// end.seconds += 1;
/// end.nanos -= 1000000000;
/// }
/// ```
/// A Timestamp represents a point in time independent of any time zone or local calendar, encoded
/// as a count of seconds and fractions of seconds at nanosecond resolution. The count is relative
/// to an epoch at UTC midnight on January 1, 1970, in the proleptic Gregorian calendar which
/// extends the Gregorian calendar backwards indefinitely.
///
/// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap second table is
/// needed for interpretation, using a [24-hour linear smear](
/// <https://developers.google.com/time/smear>).
///
/// The range from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z may be converted to and
/// from [RFC 3339](<https://www.ietf.org/rfc/rfc3339.txt>) date strings via the `Display` and
/// `FromStr` traits. Dates before and after those years are extended further, still in the
/// proleptic Gregorian calendar, in negative years or in positive years with more than 4 digits.
///
/// Values of this type are not guaranteed to only exist in their normalized form.
/// `Value` represents a dynamically typed JSON value which can be either null, a number (signed,
/// unsigned, or floating point in 64 bits), a string, a boolean, a string-keyed associative map of
/// other values, or a list of values.
/// `StructValue` represents a structured data value analogous to a JSON object value.
/// `ListValue` is a wrapper around a repeated list of values, analogous to a JSON list value.