summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLDateTime.m
blob: 88c691c898846dd07ad922a85cd56587a4886ad0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//  SDLDateTime.m
//

#import "SDLDateTime.h"

#import "NSMutableDictionary+Store.h"
#import "SDLNames.h"

@implementation SDLDateTime

- (instancetype)initWithHour:(UInt8)hour minute:(UInt8)minute {
    self = [self init];
    if (!self) {
        return nil;
    }

    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);

    return self;
}

- (void)setMillisecond:(NSNumber<SDLInt> *)millisecond {
    [store sdl_setObject:millisecond forName:SDLNameMillisecond];
}

- (NSNumber<SDLInt> *)millisecond {
    return [store sdl_objectForName:SDLNameMillisecond];
}

- (void)setSecond:(NSNumber<SDLInt> *)second {
    [store sdl_setObject:second forName:SDLNameSecond];
}

- (NSNumber<SDLInt> *)second {
    return [store sdl_objectForName:SDLNameSecond];
}

- (void)setMinute:(NSNumber<SDLInt> *)minute {
    [store sdl_setObject:minute forName:SDLNameMinute];
}

- (NSNumber<SDLInt> *)minute {
    return [store sdl_objectForName:SDLNameMinute];
}

- (void)setHour:(NSNumber<SDLInt> *)hour {
    [store sdl_setObject:hour forName:SDLNameHour];
}

- (NSNumber<SDLInt> *)hour {
    return [store sdl_objectForName:SDLNameHour];
}

- (void)setDay:(NSNumber<SDLInt> *)day {
    [store sdl_setObject:day forName:SDLNameDay];
}

- (NSNumber<SDLInt> *)day {
    return [store sdl_objectForName:SDLNameDay];
}

- (void)setMonth:(NSNumber<SDLInt> *)month {
    [store sdl_setObject:month forName:SDLNameMonth];
}

- (NSNumber<SDLInt> *)month {
    return [store sdl_objectForName:SDLNameMonth];
}

- (void)setYear:(NSNumber<SDLInt> *)year {
    [store sdl_setObject:year forName:SDLNameYear];
}

- (NSNumber<SDLInt> *)year {
    return [store sdl_objectForName:SDLNameYear];
}

- (void)setTimezoneMinuteOffset:(NSNumber<SDLInt> *)timezoneMinuteOffset {
    [store sdl_setObject:timezoneMinuteOffset forName:SDLNameTimezoneMinuteOffset];
}

- (NSNumber<SDLInt> *)timezoneMinuteOffset {
    return [store sdl_objectForName:SDLNameTimezoneMinuteOffset];
}

- (void)setTimezoneHourOffset:(NSNumber<SDLInt> *)timezoneHourOffset {
    [store sdl_setObject:timezoneHourOffset forName:SDLNameTimezoneHourOffset];
}

- (NSNumber<SDLInt> *)timezoneHourOffset {
    return [store sdl_objectForName:SDLNameTimezoneHourOffset];
}

@end