GPBTimestamp.pbobjc.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // Generated by the protocol buffer compiler. DO NOT EDIT!
  2. // clang-format off
  3. // source: google/protobuf/timestamp.proto
  4. #import "GPBDescriptor.h"
  5. #import "GPBMessage.h"
  6. #import "GPBRootObject.h"
  7. #if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
  8. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
  9. #endif
  10. #if 30007 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
  11. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
  12. #endif
  13. // @@protoc_insertion_point(imports)
  14. #pragma clang diagnostic push
  15. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  16. CF_EXTERN_C_BEGIN
  17. NS_ASSUME_NONNULL_BEGIN
  18. #pragma mark - GPBTimestampRoot
  19. /**
  20. * Exposes the extension registry for this file.
  21. *
  22. * The base class provides:
  23. * @code
  24. * + (GPBExtensionRegistry *)extensionRegistry;
  25. * @endcode
  26. * which is a @c GPBExtensionRegistry that includes all the extensions defined by
  27. * this file and all files that it depends on.
  28. **/
  29. GPB_FINAL @interface GPBTimestampRoot : GPBRootObject
  30. @end
  31. #pragma mark - GPBTimestamp
  32. typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
  33. GPBTimestamp_FieldNumber_Seconds = 1,
  34. GPBTimestamp_FieldNumber_Nanos = 2,
  35. };
  36. /**
  37. * A Timestamp represents a point in time independent of any time zone or local
  38. * calendar, encoded as a count of seconds and fractions of seconds at
  39. * nanosecond resolution. The count is relative to an epoch at UTC midnight on
  40. * January 1, 1970, in the proleptic Gregorian calendar which extends the
  41. * Gregorian calendar backwards to year one.
  42. *
  43. * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
  44. * second table is needed for interpretation, using a [24-hour linear
  45. * smear](https://developers.google.com/time/smear).
  46. *
  47. * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
  48. * restricting to that range, we ensure that we can convert to and from [RFC
  49. * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
  50. *
  51. * # Examples
  52. *
  53. * Example 1: Compute Timestamp from POSIX `time()`.
  54. *
  55. * Timestamp timestamp;
  56. * timestamp.set_seconds(time(NULL));
  57. * timestamp.set_nanos(0);
  58. *
  59. * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
  60. *
  61. * struct timeval tv;
  62. * gettimeofday(&tv, NULL);
  63. *
  64. * Timestamp timestamp;
  65. * timestamp.set_seconds(tv.tv_sec);
  66. * timestamp.set_nanos(tv.tv_usec * 1000);
  67. *
  68. * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
  69. *
  70. * FILETIME ft;
  71. * GetSystemTimeAsFileTime(&ft);
  72. * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
  73. *
  74. * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
  75. * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
  76. * Timestamp timestamp;
  77. * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
  78. * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
  79. *
  80. * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
  81. *
  82. * long millis = System.currentTimeMillis();
  83. *
  84. * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
  85. * .setNanos((int) ((millis % 1000) * 1000000)).build();
  86. *
  87. * Example 5: Compute Timestamp from Java `Instant.now()`.
  88. *
  89. * Instant now = Instant.now();
  90. *
  91. * Timestamp timestamp =
  92. * Timestamp.newBuilder().setSeconds(now.getEpochSecond())
  93. * .setNanos(now.getNano()).build();
  94. *
  95. * Example 6: Compute Timestamp from current time in Python.
  96. *
  97. * timestamp = Timestamp()
  98. * timestamp.GetCurrentTime()
  99. *
  100. * # JSON Mapping
  101. *
  102. * In JSON format, the Timestamp type is encoded as a string in the
  103. * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
  104. * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
  105. * where {year} is always expressed using four digits while {month}, {day},
  106. * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
  107. * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
  108. * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
  109. * is required. A proto3 JSON serializer should always use UTC (as indicated by
  110. * "Z") when printing the Timestamp type and a proto3 JSON parser should be
  111. * able to accept both UTC and other timezones (as indicated by an offset).
  112. *
  113. * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
  114. * 01:30 UTC on January 15, 2017.
  115. *
  116. * In JavaScript, one can convert a Date object to this format using the
  117. * standard
  118. * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
  119. * method. In Python, a standard `datetime.datetime` object can be converted
  120. * to this format using
  121. * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
  122. * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
  123. * the Joda Time's [`ISODateTimeFormat.dateTime()`](
  124. * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
  125. * ) to obtain a formatter capable of generating timestamps in this format.
  126. **/
  127. GPB_FINAL @interface GPBTimestamp : GPBMessage
  128. /**
  129. * Represents seconds of UTC time since Unix epoch
  130. * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
  131. * 9999-12-31T23:59:59Z inclusive.
  132. **/
  133. @property(nonatomic, readwrite) int64_t seconds;
  134. /**
  135. * Non-negative fractions of a second at nanosecond resolution. Negative
  136. * second values with fractions must still have non-negative nanos values
  137. * that count forward in time. Must be from 0 to 999,999,999
  138. * inclusive.
  139. **/
  140. @property(nonatomic, readwrite) int32_t nanos;
  141. // NOTE: There are some Objective-C specific methods/properties in
  142. // GPBWellKnownTypes.h that will likey be useful.
  143. @end
  144. NS_ASSUME_NONNULL_END
  145. CF_EXTERN_C_END
  146. #pragma clang diagnostic pop
  147. // @@protoc_insertion_point(global_scope)
  148. // clang-format on