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