Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing android whitespace error #873

Merged
merged 3 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions ios/RNDatePicker.mm
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ + (ComponentDescriptorProvider)componentDescriptorProvider
}
#endif

NSDate* unixMillisToNSDate (double unixMillis) {
double time = unixMillis/1000.0;
return [NSDate dateWithTimeIntervalSince1970: time];
NSDate* iso8601StringToNSDate(const std::string &iso8601String) {
NSString *nsString = [NSString stringWithUTF8String:iso8601String.c_str()];
NSISO8601DateFormatter *isoFormatter = [[NSISO8601DateFormatter alloc] init];
NSDate *date = [isoFormatter dateFromString:nsString];
return date;
}

#ifdef RCT_NEW_ARCH_ENABLED
Expand Down Expand Up @@ -101,7 +103,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &

// date
if(oldViewProps.date != newViewProps.date) {
[_picker setDate: unixMillisToNSDate(newViewProps.date)];
[_picker setDate: iso8601StringToNSDate(newViewProps.date)];
}

// locale
Expand All @@ -113,12 +115,12 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &

// maximumDate
if(oldViewProps.maximumDate != newViewProps.maximumDate) {
[_picker setMaximumDate: unixMillisToNSDate(newViewProps.maximumDate)];
[_picker setMaximumDate: iso8601StringToNSDate(newViewProps.maximumDate)];
}

// minimumDate
if(oldViewProps.minimumDate != newViewProps.minimumDate) {
[_picker setMinimumDate: unixMillisToNSDate(newViewProps.minimumDate)];
[_picker setMinimumDate: iso8601StringToNSDate(newViewProps.minimumDate)];
}

// setMinuteInterval
Expand Down
6 changes: 3 additions & 3 deletions ios/RNDatePickerManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ - (UIView *)view
}

RCT_EXPORT_VIEW_PROPERTY(text, NSString)
RCT_EXPORT_VIEW_PROPERTY(date, NSDate)
RCT_EXPORT_VIEW_PROPERTY(date, NSString)
RCT_EXPORT_VIEW_PROPERTY(locale, NSLocale)
RCT_EXPORT_VIEW_PROPERTY(minimumDate, NSDate)
RCT_EXPORT_VIEW_PROPERTY(maximumDate, NSDate)
RCT_EXPORT_VIEW_PROPERTY(minimumDate, NSString)
RCT_EXPORT_VIEW_PROPERTY(maximumDate, NSString)
RCT_EXPORT_VIEW_PROPERTY(minuteInterval, NSInteger)
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
RCT_REMAP_VIEW_PROPERTY(mode, datePickerMode, UIDatePickerMode)
Expand Down
6 changes: 3 additions & 3 deletions src/fabric/RNDatePickerNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ type DateEvent = {

export interface NativeProps extends ViewProps {
locale?: string
date: Double
maximumDate?: Double
minimumDate?: Double
date: string
maximumDate?: string
minimumDate?: string
minuteInterval?: Int32
mode?: WithDefault<'date' | 'time' | 'datetime', 'datetime'>
onChange: BubblingEventHandler<DateEvent>
Expand Down
Loading