@@ -30,16 +30,49 @@ @implementation RNDatePickerManager
30
30
// Keep: Required for RN built in Event Emitter Calls.
31
31
}
32
32
33
+ - (NSDate *)convertToNSDate : (id )input {
34
+ if (!input) return nil ;
35
+ std::string isoString = [input UTF8String ];
36
+ NSString *nsString = [NSString stringWithUTF8String: isoString.c_str ()];
37
+ NSISO8601DateFormatter *isoFormatter = [[NSISO8601DateFormatter alloc ] init ];
38
+ isoFormatter.formatOptions = NSISO8601DateFormatWithInternetDateTime | NSISO8601DateFormatWithFractionalSeconds ;
39
+ NSDate *date = [isoFormatter dateFromString: nsString];
40
+ return date;
41
+ }
42
+
33
43
- (UIView *)view
34
44
{
35
45
return [RNDatePicker new ];
36
46
}
37
47
38
48
RCT_EXPORT_VIEW_PROPERTY (text, NSString )
39
- RCT_EXPORT_VIEW_PROPERTY(date, NSString )
49
+
50
+ RCT_CUSTOM_VIEW_PROPERTY(date, id , RNDatePicker)
51
+ {
52
+ NSDate *date = [self convertToNSDate: json];
53
+ if (date) {
54
+ [(RNDatePicker *)view setDate: date];
55
+ }
56
+ }
57
+
40
58
RCT_EXPORT_VIEW_PROPERTY (locale, NSLocale )
41
- RCT_EXPORT_VIEW_PROPERTY(minimumDate, NSString )
42
- RCT_EXPORT_VIEW_PROPERTY(maximumDate, NSString )
59
+
60
+ RCT_CUSTOM_VIEW_PROPERTY(minimumDate, id , RNDatePicker)
61
+ {
62
+ NSDate *date = [self convertToNSDate: json];
63
+ if (date) {
64
+ [(RNDatePicker *)view setMinimumDate: date];
65
+ }
66
+ }
67
+
68
+ RCT_CUSTOM_VIEW_PROPERTY (maximumDate, id , RNDatePicker)
69
+ {
70
+ NSDate *date = [self convertToNSDate: json];
71
+ if (date) {
72
+ [(RNDatePicker *)view setMaximumDate: date];
73
+ }
74
+ }
75
+
43
76
RCT_EXPORT_VIEW_PROPERTY (minuteInterval, NSInteger )
44
77
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
45
78
RCT_REMAP_VIEW_PROPERTY(mode, datePickerMode, UIDatePickerMode)
0 commit comments