GPBTimestamp.pbobjc.h 5.7 KB

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