timestamp.pb.swift 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * DO NOT EDIT.
  3. *
  4. * Generated by the protocol buffer compiler.
  5. * Source: google/protobuf/timestamp.proto
  6. *
  7. */
  8. /// A Timestamp represents a point in time independent of any time zone
  9. /// or calendar, represented as seconds and fractions of seconds at
  10. /// nanosecond resolution in UTC Epoch time. It is encoded using the
  11. /// Proleptic Gregorian Calendar which extends the Gregorian calendar
  12. /// backwards to year one. It is encoded assuming all minutes are 60
  13. /// seconds long, i.e. leap seconds are "smeared" so that no leap second
  14. /// table is needed for interpretation. Range is from
  15. /// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
  16. /// By restricting to that range, we ensure that we can convert to
  17. /// and from RFC 3339 date strings.
  18. /// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
  19. ///
  20. /// Example 1: Compute Timestamp from POSIX `time()`.
  21. ///
  22. /// Timestamp timestamp;
  23. /// timestamp.set_seconds(time(NULL));
  24. /// timestamp.set_nanos(0);
  25. ///
  26. /// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
  27. ///
  28. /// struct timeval tv;
  29. /// gettimeofday(&tv, NULL);
  30. ///
  31. /// Timestamp timestamp;
  32. /// timestamp.set_seconds(tv.tv_sec);
  33. /// timestamp.set_nanos(tv.tv_usec * 1000);
  34. ///
  35. /// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
  36. ///
  37. /// FILETIME ft;
  38. /// GetSystemTimeAsFileTime(&ft);
  39. /// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
  40. ///
  41. /// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
  42. /// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
  43. /// Timestamp timestamp;
  44. /// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
  45. /// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
  46. ///
  47. /// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
  48. ///
  49. /// long millis = System.currentTimeMillis();
  50. ///
  51. /// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
  52. /// .setNanos((int) ((millis % 1000) * 1000000)).build();
  53. ///
  54. ///
  55. /// Example 5: Compute Timestamp from current time in Python.
  56. ///
  57. /// now = time.time()
  58. /// seconds = int(now)
  59. /// nanos = int((now - seconds) * 10**9)
  60. /// timestamp = Timestamp(seconds=seconds, nanos=nanos)
  61. public struct Google_Protobuf_Timestamp: ProtobufGeneratedMessage {
  62. public var swiftClassName: String {return "Google_Protobuf_Timestamp"}
  63. public var protoMessageName: String {return "Timestamp"}
  64. public var protoPackageName: String {return "google.protobuf"}
  65. public var jsonFieldNames: [String: Int] {return [
  66. "seconds": 1,
  67. "nanos": 2,
  68. ]}
  69. public var protoFieldNames: [String: Int] {return [
  70. "seconds": 1,
  71. "nanos": 2,
  72. ]}
  73. /// Represents seconds of UTC time since Unix epoch
  74. /// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to
  75. /// 9999-12-31T23:59:59Z inclusive.
  76. public var seconds: Int64 = 0
  77. /// Non-negative fractions of a second at nanosecond resolution. Negative
  78. /// second values with fractions must still have non-negative nanos values
  79. /// that count forward in time. Must be from 0 to 999,999,999
  80. /// inclusive.
  81. public var nanos: Int32 = 0
  82. public init() {}
  83. public init(seconds: Int64? = nil,
  84. nanos: Int32? = nil)
  85. {
  86. if let v = seconds {
  87. self.seconds = v
  88. }
  89. if let v = nanos {
  90. self.nanos = v
  91. }
  92. }
  93. public mutating func _protoc_generated_decodeField(setter: inout ProtobufFieldDecoder, protoFieldNumber: Int) throws -> Bool {
  94. let handled: Bool
  95. switch protoFieldNumber {
  96. case 1: handled = try setter.decodeSingularField(fieldType: ProtobufInt64.self, value: &seconds)
  97. case 2: handled = try setter.decodeSingularField(fieldType: ProtobufInt32.self, value: &nanos)
  98. default:
  99. handled = false
  100. }
  101. return handled
  102. }
  103. public func _protoc_generated_traverse(visitor: inout ProtobufVisitor) throws {
  104. if seconds != 0 {
  105. try visitor.visitSingularField(fieldType: ProtobufInt64.self, value: seconds, protoFieldNumber: 1, protoFieldName: "seconds", jsonFieldName: "seconds", swiftFieldName: "seconds")
  106. }
  107. if nanos != 0 {
  108. try visitor.visitSingularField(fieldType: ProtobufInt32.self, value: nanos, protoFieldNumber: 2, protoFieldName: "nanos", jsonFieldName: "nanos", swiftFieldName: "nanos")
  109. }
  110. }
  111. public var _protoc_generated_isEmpty: Bool {
  112. if seconds != 0 {return false}
  113. if nanos != 0 {return false}
  114. return true
  115. }
  116. public func _protoc_generated_isEqualTo(other: Google_Protobuf_Timestamp) -> Bool {
  117. if seconds != other.seconds {return false}
  118. if nanos != other.nanos {return false}
  119. return true
  120. }
  121. }