Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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