diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2017-01-12 17:13:10 -0500 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2017-01-12 19:33:25 -0500 |
commit | d0bc096b4a4b94cc62ce00541afb74860392df9c (patch) | |
tree | 9e0f6949c80b0a9ed8e196005b7ea055849d0303 /objectivec/GPBWellKnownTypes.h | |
parent | c9cd6acd71e928164db10602b9d0837216ee367e (diff) | |
download | protobuf-d0bc096b4a4b94cc62ce00541afb74860392df9c.tar.gz protobuf-d0bc096b4a4b94cc62ce00541afb74860392df9c.tar.bz2 protobuf-d0bc096b4a4b94cc62ce00541afb74860392df9c.zip |
Timestamp helper fix, Duration helper cleanup.
- The Timestamp proto does not allow for negative nanos fields, so the seconds
must be shifted and a positive nanos then applied.
- Tweak the helpers on Duration to make it clear there is no "base" time
involved.
- Update the unittests for duration and timestamp to cover positive and
negative NSTimeIntervals and what their impact is on the protos.
Diffstat (limited to 'objectivec/GPBWellKnownTypes.h')
-rw-r--r-- | objectivec/GPBWellKnownTypes.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/objectivec/GPBWellKnownTypes.h b/objectivec/GPBWellKnownTypes.h index 90d96c6f..04df4178 100644 --- a/objectivec/GPBWellKnownTypes.h +++ b/objectivec/GPBWellKnownTypes.h @@ -112,16 +112,27 @@ typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) { * @note: Not all second/nanos combinations can be represented in a * NSTimeInterval, so getting this could be a lossy transform. **/ -@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970; +@property(nonatomic, readwrite) NSTimeInterval timeInterval; /** * Initializes a GPBDuration with the given NSTimeInterval. * - * @param timeIntervalSince1970 Time interval to configure the GPBDuration with. + * @param timeInterval Time interval to configure the GPBDuration with. * * @return A newly initialized GPBDuration. **/ -- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970; +- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval; + +// These next two methods are deprecated because GBPDuration has no need of a +// "base" time. The older methods were about symmetry with GBPTimestamp, but +// the unix epoch usage is too confusing. + +/** Deprecated, use timeInterval instead. */ +@property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970 + __attribute__((deprecated("Use timeInterval"))); +/** Deprecated, use initWithTimeInterval: instead. */ +- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970 + __attribute__((deprecated("Use initWithTimeInterval:"))); @end |