You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

391 lines
14 KiB

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