blob: c9ae92132aade6b1dd4196d983c60f4622ea43d0 [file] [log] [blame]
khenaidood948f772021-08-11 17:49:24 -04001// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc. All rights reserved.
3// https://developers.google.com/protocol-buffers/
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above
12// copyright notice, this list of conditions and the following disclaimer
13// in the documentation and/or other materials provided with the
14// distribution.
15// * Neither the name of Google Inc. nor the names of its
16// contributors may be used to endorse or promote products derived from
17// this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
30
31// Code generated by protoc-gen-go. DO NOT EDIT.
32// source: google/protobuf/timestamp.proto
33
34// Package timestamppb contains generated types for google/protobuf/timestamp.proto.
35//
36// The Timestamp message represents a timestamp,
37// an instant in time since the Unix epoch (January 1st, 1970).
38//
39//
40// Conversion to a Go Time
41//
42// The AsTime method can be used to convert a Timestamp message to a
43// standard Go time.Time value in UTC:
44//
45// t := ts.AsTime()
46// ... // make use of t as a time.Time
47//
48// Converting to a time.Time is a common operation so that the extensive
49// set of time-based operations provided by the time package can be leveraged.
50// See https://golang.org/pkg/time for more information.
51//
52// The AsTime method performs the conversion on a best-effort basis. Timestamps
53// with denormal values (e.g., nanoseconds beyond 0 and 99999999, inclusive)
54// are normalized during the conversion to a time.Time. To manually check for
55// invalid Timestamps per the documented limitations in timestamp.proto,
56// additionally call the CheckValid method:
57//
58// if err := ts.CheckValid(); err != nil {
59// ... // handle error
60// }
61//
62//
63// Conversion from a Go Time
64//
65// The timestamppb.New function can be used to construct a Timestamp message
66// from a standard Go time.Time value:
67//
68// ts := timestamppb.New(t)
69// ... // make use of ts as a *timestamppb.Timestamp
70//
71// In order to construct a Timestamp representing the current time, use Now:
72//
73// ts := timestamppb.Now()
74// ... // make use of ts as a *timestamppb.Timestamp
75//
76package timestamppb
77
78import (
79 protoreflect "google.golang.org/protobuf/reflect/protoreflect"
80 protoimpl "google.golang.org/protobuf/runtime/protoimpl"
81 reflect "reflect"
82 sync "sync"
83 time "time"
84)
85
86// A Timestamp represents a point in time independent of any time zone or local
87// calendar, encoded as a count of seconds and fractions of seconds at
88// nanosecond resolution. The count is relative to an epoch at UTC midnight on
89// January 1, 1970, in the proleptic Gregorian calendar which extends the
90// Gregorian calendar backwards to year one.
91//
92// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
93// second table is needed for interpretation, using a [24-hour linear
94// smear](https://developers.google.com/time/smear).
95//
96// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
97// restricting to that range, we ensure that we can convert to and from [RFC
98// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
99//
100// # Examples
101//
102// Example 1: Compute Timestamp from POSIX `time()`.
103//
104// Timestamp timestamp;
105// timestamp.set_seconds(time(NULL));
106// timestamp.set_nanos(0);
107//
108// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
109//
110// struct timeval tv;
111// gettimeofday(&tv, NULL);
112//
113// Timestamp timestamp;
114// timestamp.set_seconds(tv.tv_sec);
115// timestamp.set_nanos(tv.tv_usec * 1000);
116//
117// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
118//
119// FILETIME ft;
120// GetSystemTimeAsFileTime(&ft);
121// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
122//
123// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
124// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
125// Timestamp timestamp;
126// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
127// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
128//
129// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
130//
131// long millis = System.currentTimeMillis();
132//
133// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
134// .setNanos((int) ((millis % 1000) * 1000000)).build();
135//
136//
137// Example 5: Compute Timestamp from Java `Instant.now()`.
138//
139// Instant now = Instant.now();
140//
141// Timestamp timestamp =
142// Timestamp.newBuilder().setSeconds(now.getEpochSecond())
143// .setNanos(now.getNano()).build();
144//
145//
146// Example 6: Compute Timestamp from current time in Python.
147//
148// timestamp = Timestamp()
149// timestamp.GetCurrentTime()
150//
151// # JSON Mapping
152//
153// In JSON format, the Timestamp type is encoded as a string in the
154// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
155// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
156// where {year} is always expressed using four digits while {month}, {day},
157// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
158// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
159// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
160// is required. A proto3 JSON serializer should always use UTC (as indicated by
161// "Z") when printing the Timestamp type and a proto3 JSON parser should be
162// able to accept both UTC and other timezones (as indicated by an offset).
163//
164// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
165// 01:30 UTC on January 15, 2017.
166//
167// In JavaScript, one can convert a Date object to this format using the
168// standard
169// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
170// method. In Python, a standard `datetime.datetime` object can be converted
171// to this format using
172// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
173// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
174// the Joda Time's [`ISODateTimeFormat.dateTime()`](
175// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
176// ) to obtain a formatter capable of generating timestamps in this format.
177//
178//
179type Timestamp struct {
180 state protoimpl.MessageState
181 sizeCache protoimpl.SizeCache
182 unknownFields protoimpl.UnknownFields
183
184 // Represents seconds of UTC time since Unix epoch
185 // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
186 // 9999-12-31T23:59:59Z inclusive.
187 Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
188 // Non-negative fractions of a second at nanosecond resolution. Negative
189 // second values with fractions must still have non-negative nanos values
190 // that count forward in time. Must be from 0 to 999,999,999
191 // inclusive.
192 Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
193}
194
195// Now constructs a new Timestamp from the current time.
196func Now() *Timestamp {
197 return New(time.Now())
198}
199
200// New constructs a new Timestamp from the provided time.Time.
201func New(t time.Time) *Timestamp {
202 return &Timestamp{Seconds: int64(t.Unix()), Nanos: int32(t.Nanosecond())}
203}
204
205// AsTime converts x to a time.Time.
206func (x *Timestamp) AsTime() time.Time {
207 return time.Unix(int64(x.GetSeconds()), int64(x.GetNanos())).UTC()
208}
209
210// IsValid reports whether the timestamp is valid.
211// It is equivalent to CheckValid == nil.
212func (x *Timestamp) IsValid() bool {
213 return x.check() == 0
214}
215
216// CheckValid returns an error if the timestamp is invalid.
217// In particular, it checks whether the value represents a date that is
218// in the range of 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.
219// An error is reported for a nil Timestamp.
220func (x *Timestamp) CheckValid() error {
221 switch x.check() {
222 case invalidNil:
223 return protoimpl.X.NewError("invalid nil Timestamp")
224 case invalidUnderflow:
225 return protoimpl.X.NewError("timestamp (%v) before 0001-01-01", x)
226 case invalidOverflow:
227 return protoimpl.X.NewError("timestamp (%v) after 9999-12-31", x)
228 case invalidNanos:
229 return protoimpl.X.NewError("timestamp (%v) has out-of-range nanos", x)
230 default:
231 return nil
232 }
233}
234
235const (
236 _ = iota
237 invalidNil
238 invalidUnderflow
239 invalidOverflow
240 invalidNanos
241)
242
243func (x *Timestamp) check() uint {
244 const minTimestamp = -62135596800 // Seconds between 1970-01-01T00:00:00Z and 0001-01-01T00:00:00Z, inclusive
245 const maxTimestamp = +253402300799 // Seconds between 1970-01-01T00:00:00Z and 9999-12-31T23:59:59Z, inclusive
246 secs := x.GetSeconds()
247 nanos := x.GetNanos()
248 switch {
249 case x == nil:
250 return invalidNil
251 case secs < minTimestamp:
252 return invalidUnderflow
253 case secs > maxTimestamp:
254 return invalidOverflow
255 case nanos < 0 || nanos >= 1e9:
256 return invalidNanos
257 default:
258 return 0
259 }
260}
261
262func (x *Timestamp) Reset() {
263 *x = Timestamp{}
264 if protoimpl.UnsafeEnabled {
265 mi := &file_google_protobuf_timestamp_proto_msgTypes[0]
266 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
267 ms.StoreMessageInfo(mi)
268 }
269}
270
271func (x *Timestamp) String() string {
272 return protoimpl.X.MessageStringOf(x)
273}
274
275func (*Timestamp) ProtoMessage() {}
276
277func (x *Timestamp) ProtoReflect() protoreflect.Message {
278 mi := &file_google_protobuf_timestamp_proto_msgTypes[0]
279 if protoimpl.UnsafeEnabled && x != nil {
280 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
281 if ms.LoadMessageInfo() == nil {
282 ms.StoreMessageInfo(mi)
283 }
284 return ms
285 }
286 return mi.MessageOf(x)
287}
288
289// Deprecated: Use Timestamp.ProtoReflect.Descriptor instead.
290func (*Timestamp) Descriptor() ([]byte, []int) {
291 return file_google_protobuf_timestamp_proto_rawDescGZIP(), []int{0}
292}
293
294func (x *Timestamp) GetSeconds() int64 {
295 if x != nil {
296 return x.Seconds
297 }
298 return 0
299}
300
301func (x *Timestamp) GetNanos() int32 {
302 if x != nil {
303 return x.Nanos
304 }
305 return 0
306}
307
308var File_google_protobuf_timestamp_proto protoreflect.FileDescriptor
309
310var file_google_protobuf_timestamp_proto_rawDesc = []byte{
311 0x0a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
312 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74,
313 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
314 0x75, 0x66, 0x22, 0x3b, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12,
315 0x18, 0x0a, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
316 0x52, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6e,
317 0x6f, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x42,
318 0x85, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
319 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x0e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
320 0x6d, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
321 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f,
322 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x6b, 0x6e, 0x6f, 0x77,
323 0x6e, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x70, 0x62, 0xf8, 0x01, 0x01,
324 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
325 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f,
326 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
327}
328
329var (
330 file_google_protobuf_timestamp_proto_rawDescOnce sync.Once
331 file_google_protobuf_timestamp_proto_rawDescData = file_google_protobuf_timestamp_proto_rawDesc
332)
333
334func file_google_protobuf_timestamp_proto_rawDescGZIP() []byte {
335 file_google_protobuf_timestamp_proto_rawDescOnce.Do(func() {
336 file_google_protobuf_timestamp_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_timestamp_proto_rawDescData)
337 })
338 return file_google_protobuf_timestamp_proto_rawDescData
339}
340
341var file_google_protobuf_timestamp_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
342var file_google_protobuf_timestamp_proto_goTypes = []interface{}{
343 (*Timestamp)(nil), // 0: google.protobuf.Timestamp
344}
345var file_google_protobuf_timestamp_proto_depIdxs = []int32{
346 0, // [0:0] is the sub-list for method output_type
347 0, // [0:0] is the sub-list for method input_type
348 0, // [0:0] is the sub-list for extension type_name
349 0, // [0:0] is the sub-list for extension extendee
350 0, // [0:0] is the sub-list for field type_name
351}
352
353func init() { file_google_protobuf_timestamp_proto_init() }
354func file_google_protobuf_timestamp_proto_init() {
355 if File_google_protobuf_timestamp_proto != nil {
356 return
357 }
358 if !protoimpl.UnsafeEnabled {
359 file_google_protobuf_timestamp_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
360 switch v := v.(*Timestamp); i {
361 case 0:
362 return &v.state
363 case 1:
364 return &v.sizeCache
365 case 2:
366 return &v.unknownFields
367 default:
368 return nil
369 }
370 }
371 }
372 type x struct{}
373 out := protoimpl.TypeBuilder{
374 File: protoimpl.DescBuilder{
375 GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
376 RawDescriptor: file_google_protobuf_timestamp_proto_rawDesc,
377 NumEnums: 0,
378 NumMessages: 1,
379 NumExtensions: 0,
380 NumServices: 0,
381 },
382 GoTypes: file_google_protobuf_timestamp_proto_goTypes,
383 DependencyIndexes: file_google_protobuf_timestamp_proto_depIdxs,
384 MessageInfos: file_google_protobuf_timestamp_proto_msgTypes,
385 }.Build()
386 File_google_protobuf_timestamp_proto = out.File
387 file_google_protobuf_timestamp_proto_rawDesc = nil
388 file_google_protobuf_timestamp_proto_goTypes = nil
389 file_google_protobuf_timestamp_proto_depIdxs = nil
390}