| OLD | NEW |
| 1 // Generated by the protocol buffer compiler. DO NOT EDIT! | 1 // Generated by the protocol buffer compiler. DO NOT EDIT! |
| 2 // source: google/protobuf/duration.proto | 2 // source: google/protobuf/duration.proto |
| 3 | 3 |
| 4 #import "GPBProtocolBuffers.h" | 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 |
| 5 | 9 |
| 6 #if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30001 | 10 #if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS |
| 7 #error This file was generated by a different version of protoc which is incompa
tible with your Protocol Buffer library sources. | 11 #import <Protobuf/GPBProtocolBuffers.h> |
| 12 #else |
| 13 #import "GPBProtocolBuffers.h" |
| 14 #endif |
| 15 |
| 16 #if GOOGLE_PROTOBUF_OBJC_VERSION < 30002 |
| 17 #error This file was generated by a newer version of protoc which is incompatibl
e with your Protocol Buffer library sources. |
| 18 #endif |
| 19 #if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION |
| 20 #error This file was generated by an older version of protoc which is incompatib
le with your Protocol Buffer library sources. |
| 8 #endif | 21 #endif |
| 9 | 22 |
| 10 // @@protoc_insertion_point(imports) | 23 // @@protoc_insertion_point(imports) |
| 11 | 24 |
| 12 #pragma clang diagnostic push | 25 #pragma clang diagnostic push |
| 13 #pragma clang diagnostic ignored "-Wdeprecated-declarations" | 26 #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
| 14 | 27 |
| 15 CF_EXTERN_C_BEGIN | 28 CF_EXTERN_C_BEGIN |
| 16 | 29 |
| 17 NS_ASSUME_NONNULL_BEGIN | 30 NS_ASSUME_NONNULL_BEGIN |
| 18 | 31 |
| 19 #pragma mark - GPBDurationRoot | 32 #pragma mark - GPBDurationRoot |
| 20 | 33 |
| 21 /// Exposes the extension registry for this file. | 34 /** |
| 22 /// | 35 * Exposes the extension registry for this file. |
| 23 /// The base class provides: | 36 * |
| 24 /// @code | 37 * The base class provides: |
| 25 /// + (GPBExtensionRegistry *)extensionRegistry; | 38 * @code |
| 26 /// @endcode | 39 * + (GPBExtensionRegistry *)extensionRegistry; |
| 27 /// which is a @c GPBExtensionRegistry that includes all the extensions defined
by | 40 * @endcode |
| 28 /// this file and all files that it depends on. | 41 * which is a @c GPBExtensionRegistry that includes all the extensions defined b
y |
| 42 * this file and all files that it depends on. |
| 43 **/ |
| 29 @interface GPBDurationRoot : GPBRootObject | 44 @interface GPBDurationRoot : GPBRootObject |
| 30 @end | 45 @end |
| 31 | 46 |
| 32 #pragma mark - GPBDuration | 47 #pragma mark - GPBDuration |
| 33 | 48 |
| 34 typedef GPB_ENUM(GPBDuration_FieldNumber) { | 49 typedef GPB_ENUM(GPBDuration_FieldNumber) { |
| 35 GPBDuration_FieldNumber_Seconds = 1, | 50 GPBDuration_FieldNumber_Seconds = 1, |
| 36 GPBDuration_FieldNumber_Nanos = 2, | 51 GPBDuration_FieldNumber_Nanos = 2, |
| 37 }; | 52 }; |
| 38 | 53 |
| 39 /// A Duration represents a signed, fixed-length span of time represented | 54 /** |
| 40 /// as a count of seconds and fractions of seconds at nanosecond | 55 * A Duration represents a signed, fixed-length span of time represented |
| 41 /// resolution. It is independent of any calendar and concepts like "day" | 56 * as a count of seconds and fractions of seconds at nanosecond |
| 42 /// or "month". It is related to Timestamp in that the difference between | 57 * resolution. It is independent of any calendar and concepts like "day" |
| 43 /// two Timestamp values is a Duration and it can be added or subtracted | 58 * or "month". It is related to Timestamp in that the difference between |
| 44 /// from a Timestamp. Range is approximately +-10,000 years. | 59 * two Timestamp values is a Duration and it can be added or subtracted |
| 45 /// | 60 * from a Timestamp. Range is approximately +-10,000 years. |
| 46 /// Example 1: Compute Duration from two Timestamps in pseudo code. | 61 * |
| 47 /// | 62 * Example 1: Compute Duration from two Timestamps in pseudo code. |
| 48 /// Timestamp start = ...; | 63 * |
| 49 /// Timestamp end = ...; | 64 * Timestamp start = ...; |
| 50 /// Duration duration = ...; | 65 * Timestamp end = ...; |
| 51 /// | 66 * Duration duration = ...; |
| 52 /// duration.seconds = end.seconds - start.seconds; | 67 * |
| 53 /// duration.nanos = end.nanos - start.nanos; | 68 * duration.seconds = end.seconds - start.seconds; |
| 54 /// | 69 * duration.nanos = end.nanos - start.nanos; |
| 55 /// if (duration.seconds < 0 && duration.nanos > 0) { | 70 * |
| 56 /// duration.seconds += 1; | 71 * if (duration.seconds < 0 && duration.nanos > 0) { |
| 57 /// duration.nanos -= 1000000000; | 72 * duration.seconds += 1; |
| 58 /// } else if (durations.seconds > 0 && duration.nanos < 0) { | 73 * duration.nanos -= 1000000000; |
| 59 /// duration.seconds -= 1; | 74 * } else if (durations.seconds > 0 && duration.nanos < 0) { |
| 60 /// duration.nanos += 1000000000; | 75 * duration.seconds -= 1; |
| 61 /// } | 76 * duration.nanos += 1000000000; |
| 62 /// | 77 * } |
| 63 /// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. | 78 * |
| 64 /// | 79 * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. |
| 65 /// Timestamp start = ...; | 80 * |
| 66 /// Duration duration = ...; | 81 * Timestamp start = ...; |
| 67 /// Timestamp end = ...; | 82 * Duration duration = ...; |
| 68 /// | 83 * Timestamp end = ...; |
| 69 /// end.seconds = start.seconds + duration.seconds; | 84 * |
| 70 /// end.nanos = start.nanos + duration.nanos; | 85 * end.seconds = start.seconds + duration.seconds; |
| 71 /// | 86 * end.nanos = start.nanos + duration.nanos; |
| 72 /// if (end.nanos < 0) { | 87 * |
| 73 /// end.seconds -= 1; | 88 * if (end.nanos < 0) { |
| 74 /// end.nanos += 1000000000; | 89 * end.seconds -= 1; |
| 75 /// } else if (end.nanos >= 1000000000) { | 90 * end.nanos += 1000000000; |
| 76 /// end.seconds += 1; | 91 * } else if (end.nanos >= 1000000000) { |
| 77 /// end.nanos -= 1000000000; | 92 * end.seconds += 1; |
| 78 /// } | 93 * end.nanos -= 1000000000; |
| 94 * } |
| 95 * |
| 96 * Example 3: Compute Duration from datetime.timedelta in Python. |
| 97 * |
| 98 * td = datetime.timedelta(days=3, minutes=10) |
| 99 * duration = Duration() |
| 100 * duration.FromTimedelta(td) |
| 101 **/ |
| 79 @interface GPBDuration : GPBMessage | 102 @interface GPBDuration : GPBMessage |
| 80 | 103 |
| 81 /// Signed seconds of the span of time. Must be from -315,576,000,000 | 104 /** |
| 82 /// to +315,576,000,000 inclusive. | 105 * Signed seconds of the span of time. Must be from -315,576,000,000 |
| 106 * to +315,576,000,000 inclusive. |
| 107 **/ |
| 83 @property(nonatomic, readwrite) int64_t seconds; | 108 @property(nonatomic, readwrite) int64_t seconds; |
| 84 | 109 |
| 85 /// Signed fractions of a second at nanosecond resolution of the span | 110 /** |
| 86 /// of time. Durations less than one second are represented with a 0 | 111 * Signed fractions of a second at nanosecond resolution of the span |
| 87 /// `seconds` field and a positive or negative `nanos` field. For durations | 112 * of time. Durations less than one second are represented with a 0 |
| 88 /// of one second or more, a non-zero value for the `nanos` field must be | 113 * `seconds` field and a positive or negative `nanos` field. For durations |
| 89 /// of the same sign as the `seconds` field. Must be from -999,999,999 | 114 * of one second or more, a non-zero value for the `nanos` field must be |
| 90 /// to +999,999,999 inclusive. | 115 * of the same sign as the `seconds` field. Must be from -999,999,999 |
| 116 * to +999,999,999 inclusive. |
| 117 **/ |
| 91 @property(nonatomic, readwrite) int32_t nanos; | 118 @property(nonatomic, readwrite) int32_t nanos; |
| 92 | 119 |
| 93 @end | 120 @end |
| 94 | 121 |
| 95 NS_ASSUME_NONNULL_END | 122 NS_ASSUME_NONNULL_END |
| 96 | 123 |
| 97 CF_EXTERN_C_END | 124 CF_EXTERN_C_END |
| 98 | 125 |
| 99 #pragma clang diagnostic pop | 126 #pragma clang diagnostic pop |
| 100 | 127 |
| 101 // @@protoc_insertion_point(global_scope) | 128 // @@protoc_insertion_point(global_scope) |
| OLD | NEW |