summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuller, Alexander (A.) <amulle19@ford.com>2016-11-04 09:43:35 -0700
committerMuller, Alexander (A.) <amulle19@ford.com>2016-11-04 09:43:35 -0700
commit0c5aadcb6eb45e28556ef6f62713dcb8ec0e2b52 (patch)
treea0c629c5d2e2dc111e0807c75fe7c51b5492bd2b
parentad42cde33cb19d9cceb9f300fc3f34261c2c9b6f (diff)
downloadsdl_ios-0c5aadcb6eb45e28556ef6f62713dcb8ec0e2b52.tar.gz
Added additional initializers for SDLDateTime.
-rw-r--r--SmartDeviceLink/SDLDateTime.h26
-rw-r--r--SmartDeviceLink/SDLDateTime.m34
2 files changed, 50 insertions, 10 deletions
diff --git a/SmartDeviceLink/SDLDateTime.h b/SmartDeviceLink/SDLDateTime.h
index d858c3fe9..0f9cf6c4c 100644
--- a/SmartDeviceLink/SDLDateTime.h
+++ b/SmartDeviceLink/SDLDateTime.h
@@ -5,68 +5,76 @@
@interface SDLDateTime : SDLRPCStruct
+- (instancetype)initWithDate:(NSDate*)date;
+
+- (instancetype)initWithHour:(UInt8)hour minute:(UInt8)minute;
+
+- (instancetype)initWithHour:(UInt8)hour minute:(UInt8)minute second:(UInt8)second millisecond:(UInt16)millisecond;
+
+- (instancetype)initWithHour:(UInt8)hour minute:(UInt8)minute second:(UInt8)second millisecond:(UInt16)millisecond day:(UInt8)day month:(UInt8)month year:(UInt16)year;
+
- (instancetype)initWithHour:(UInt8)hour minute:(UInt8)minute second:(UInt8)second millisecond:(UInt16)millisecond day:(UInt8)day month:(UInt8)month year:(UInt16)year timezoneMinuteOffset:(UInt8)timezoneMinuteOffset timezoneHourOffset:(int)timezoneHourOffset;
/**
* @abstract Milliseconds part of time
*
- * Required, Integer 0 - 999
+ * Optional, Integer 0 - 999
*/
@property (copy, nonatomic) NSNumber<SDLInt> *millisecond;
/**
* @abstract Seconds part of time
*
- * Required, Integer 0 - 59
+ * Optional, Integer 0 - 59
*/
@property (copy, nonatomic) NSNumber<SDLInt> *second;
/**
* @abstract Minutes part of time
*
- * Required, Integer 0 - 59
+ * Optional, Integer 0 - 59
*/
@property (copy, nonatomic) NSNumber<SDLInt> *minute;
/**
* @abstract Hour part of time
*
- * Required, Integer 0 - 23
+ * Optional, Integer 0 - 23
*/
@property (copy, nonatomic) NSNumber<SDLInt> *hour;
/**
* @abstract Day of the month
*
- * Required, Integer 1 - 31
+ * Optional, Integer 1 - 31
*/
@property (copy, nonatomic) NSNumber<SDLInt> *day;
/**
* @abstract Month of the year
*
- * Required, Integer 1 - 12
+ * Optional, Integer 1 - 12
*/
@property (copy, nonatomic) NSNumber<SDLInt> *month;
/**
* @abstract The year in YYYY format
*
- * Required, Max Value 4095
+ * Optional, Max Value 4095
*/
@property (copy, nonatomic) NSNumber<SDLInt> *year;
/**
* @abstract Time zone offset in Min with regard to UTC
*
- * Required, Integer 0 - 59
+ * Optional, Integer 0 - 59
*/
@property (copy, nonatomic) NSNumber<SDLInt> *timezoneMinuteOffset;
/**
* @abstract Time zone offset in Hours with regard to UTC
*
- * Required, Integer -12 - 14
+ * Optional, Integer -12 - 14
*/
@property (copy, nonatomic) NSNumber<SDLInt> *timezoneHourOffset;
diff --git a/SmartDeviceLink/SDLDateTime.m b/SmartDeviceLink/SDLDateTime.m
index 20ede0638..babed159c 100644
--- a/SmartDeviceLink/SDLDateTime.m
+++ b/SmartDeviceLink/SDLDateTime.m
@@ -6,7 +6,7 @@
@implementation SDLDateTime
-- (instancetype)initWithHour:(UInt8)hour minute:(UInt8)minute second:(UInt8)second millisecond:(UInt16)millisecond day:(UInt8)day month:(UInt8)month year:(UInt16)year timezoneMinuteOffset:(UInt8)timezoneMinuteOffset timezoneHourOffset:(int)timezoneHourOffset {
+- (instancetype)initWithHour:(UInt8)hour minute:(UInt8)minute {
self = [self init];
if (!self) {
return nil;
@@ -14,11 +14,43 @@
self.hour = @(hour);
self.minute = @(minute);
+
+ return self;
+}
+
+- (instancetype)initWithHour:(UInt8)hour minute:(UInt8)minute second:(UInt8)second millisecond:(UInt16)millisecond {
+ self = [self initWithHour:hour minute:minute];
+ if (!self) {
+ return nil;
+ }
+
self.second = @(second);
self.millisecond = @(millisecond);
+
+ return self;
+
+}
+
+- (instancetype)initWithHour:(UInt8)hour minute:(UInt8)minute second:(UInt8)second millisecond:(UInt16)millisecond day:(UInt8)day month:(UInt8)month year:(UInt16)year {
+ self = [self initWithHour:hour minute:minute second:second millisecond:millisecond];
+ if (!self) {
+ return nil;
+ }
+
self.day = @(day);
self.month = @(month);
self.year = @(year);
+
+ return self;
+}
+
+
+- (instancetype)initWithHour:(UInt8)hour minute:(UInt8)minute second:(UInt8)second millisecond:(UInt16)millisecond day:(UInt8)day month:(UInt8)month year:(UInt16)year timezoneMinuteOffset:(UInt8)timezoneMinuteOffset timezoneHourOffset:(int)timezoneHourOffset {
+ self = [self initWithHour:hour minute:minute second:second millisecond:millisecond day:day month:month year:year];
+ if (!self) {
+ return nil;
+ }
+
self.timezoneMinuteOffset = @(timezoneMinuteOffset);
self.timezoneHourOffset = @(timezoneHourOffset);