timestamp.pb.swift 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // DO NOT EDIT.
  2. // swift-format-ignore-file
  3. // swiftlint:disable all
  4. //
  5. // Generated by the Swift generator plugin for the protocol buffer compiler.
  6. // Source: google/protobuf/timestamp.proto
  7. //
  8. // For information on using the generated types, please see the documentation:
  9. // https://github.com/apple/swift-protobuf/
  10. // Protocol Buffers - Google's data interchange format
  11. // Copyright 2008 Google Inc. All rights reserved.
  12. // https://developers.google.com/protocol-buffers/
  13. //
  14. // Redistribution and use in source and binary forms, with or without
  15. // modification, are permitted provided that the following conditions are
  16. // met:
  17. //
  18. // * Redistributions of source code must retain the above copyright
  19. // notice, this list of conditions and the following disclaimer.
  20. // * Redistributions in binary form must reproduce the above
  21. // copyright notice, this list of conditions and the following disclaimer
  22. // in the documentation and/or other materials provided with the
  23. // distribution.
  24. // * Neither the name of Google Inc. nor the names of its
  25. // contributors may be used to endorse or promote products derived from
  26. // this software without specific prior written permission.
  27. //
  28. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  31. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  34. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  35. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  36. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. // 'import SwiftProtobuf' suppressed, this proto file is meant to be bundled in the runtime.
  40. // If the compiler emits an error on this type, it is because this file
  41. // was generated by a version of the `protoc` Swift plug-in that is
  42. // incompatible with the version of SwiftProtobuf to which you are linking.
  43. // Please ensure that you are building against the same version of the API
  44. // that was used to generate this file.
  45. fileprivate struct _GeneratedWithProtocGenSwiftVersion: ProtobufAPIVersionCheck {
  46. struct _2: ProtobufAPIVersion_2 {}
  47. typealias Version = _2
  48. }
  49. /// A Timestamp represents a point in time independent of any time zone or local
  50. /// calendar, encoded as a count of seconds and fractions of seconds at
  51. /// nanosecond resolution. The count is relative to an epoch at UTC midnight on
  52. /// January 1, 1970, in the proleptic Gregorian calendar which extends the
  53. /// Gregorian calendar backwards to year one.
  54. ///
  55. /// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
  56. /// second table is needed for interpretation, using a [24-hour linear
  57. /// smear](https://developers.google.com/time/smear).
  58. ///
  59. /// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
  60. /// restricting to that range, we ensure that we can convert to and from [RFC
  61. /// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
  62. ///
  63. /// # Examples
  64. ///
  65. /// Example 1: Compute Timestamp from POSIX `time()`.
  66. ///
  67. /// Timestamp timestamp;
  68. /// timestamp.set_seconds(time(NULL));
  69. /// timestamp.set_nanos(0);
  70. ///
  71. /// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
  72. ///
  73. /// struct timeval tv;
  74. /// gettimeofday(&tv, NULL);
  75. ///
  76. /// Timestamp timestamp;
  77. /// timestamp.set_seconds(tv.tv_sec);
  78. /// timestamp.set_nanos(tv.tv_usec * 1000);
  79. ///
  80. /// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
  81. ///
  82. /// FILETIME ft;
  83. /// GetSystemTimeAsFileTime(&ft);
  84. /// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
  85. ///
  86. /// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
  87. /// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
  88. /// Timestamp timestamp;
  89. /// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
  90. /// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
  91. ///
  92. /// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
  93. ///
  94. /// long millis = System.currentTimeMillis();
  95. ///
  96. /// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
  97. /// .setNanos((int) ((millis % 1000) * 1000000)).build();
  98. ///
  99. /// Example 5: Compute Timestamp from Java `Instant.now()`.
  100. ///
  101. /// Instant now = Instant.now();
  102. ///
  103. /// Timestamp timestamp =
  104. /// Timestamp.newBuilder().setSeconds(now.getEpochSecond())
  105. /// .setNanos(now.getNano()).build();
  106. ///
  107. /// Example 6: Compute Timestamp from current time in Python.
  108. ///
  109. /// timestamp = Timestamp()
  110. /// timestamp.GetCurrentTime()
  111. ///
  112. /// # JSON Mapping
  113. ///
  114. /// In JSON format, the Timestamp type is encoded as a string in the
  115. /// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
  116. /// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
  117. /// where {year} is always expressed using four digits while {month}, {day},
  118. /// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
  119. /// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
  120. /// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
  121. /// is required. A ProtoJSON serializer should always use UTC (as indicated by
  122. /// "Z") when printing the Timestamp type and a ProtoJSON parser should be
  123. /// able to accept both UTC and other timezones (as indicated by an offset).
  124. ///
  125. /// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
  126. /// 01:30 UTC on January 15, 2017.
  127. ///
  128. /// In JavaScript, one can convert a Date object to this format using the
  129. /// standard
  130. /// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
  131. /// method. In Python, a standard `datetime.datetime` object can be converted
  132. /// to this format using
  133. /// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
  134. /// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
  135. /// the Joda Time's [`ISODateTimeFormat.dateTime()`](
  136. /// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
  137. /// ) to obtain a formatter capable of generating timestamps in this format.
  138. public struct Google_Protobuf_Timestamp: Sendable {
  139. // SwiftProtobuf.Message conformance is added in an extension below. See the
  140. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  141. // methods supported on all messages.
  142. /// Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must
  143. /// be between -62135596800 and 253402300799 inclusive (which corresponds to
  144. /// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z).
  145. public var seconds: Int64 = 0
  146. /// Non-negative fractions of a second at nanosecond resolution. This field is
  147. /// the nanosecond portion of the duration, not an alternative to seconds.
  148. /// Negative second values with fractions must still have non-negative nanos
  149. /// values that count forward in time. Must be between 0 and 999,999,999
  150. /// inclusive.
  151. public var nanos: Int32 = 0
  152. public var unknownFields = UnknownStorage()
  153. public init() {}
  154. }
  155. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  156. fileprivate let _protobuf_package = "google.protobuf"
  157. extension Google_Protobuf_Timestamp: Message, _MessageImplementationBase, _ProtoNameProviding {
  158. public static let protoMessageName: String = _protobuf_package + ".Timestamp"
  159. public static let _protobuf_nameMap = _NameMap(bytecode: "\0\u{1}seconds\0\u{1}nanos\0")
  160. public mutating func decodeMessage<D: Decoder>(decoder: inout D) throws {
  161. while let fieldNumber = try decoder.nextFieldNumber() {
  162. // The use of inline closures is to circumvent an issue where the compiler
  163. // allocates stack space for every case branch when no optimizations are
  164. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  165. switch fieldNumber {
  166. case 1: try { try decoder.decodeSingularInt64Field(value: &self.seconds) }()
  167. case 2: try { try decoder.decodeSingularInt32Field(value: &self.nanos) }()
  168. default: break
  169. }
  170. }
  171. }
  172. public func traverse<V: Visitor>(visitor: inout V) throws {
  173. if self.seconds != 0 {
  174. try visitor.visitSingularInt64Field(value: self.seconds, fieldNumber: 1)
  175. }
  176. if self.nanos != 0 {
  177. try visitor.visitSingularInt32Field(value: self.nanos, fieldNumber: 2)
  178. }
  179. try unknownFields.traverse(visitor: &visitor)
  180. }
  181. public static func ==(lhs: Google_Protobuf_Timestamp, rhs: Google_Protobuf_Timestamp) -> Bool {
  182. if lhs.seconds != rhs.seconds {return false}
  183. if lhs.nanos != rhs.nanos {return false}
  184. if lhs.unknownFields != rhs.unknownFields {return false}
  185. return true
  186. }
  187. }