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