Skip to content

Commit

Permalink
[android][new_arch][fix]: pass timestamp string instead of iso string…
Browse files Browse the repository at this point in the history
… to date props to fix runtime error on new architecture on android
  • Loading branch information
ice-hades committed Aug 14, 2024
1 parent 94ccd9d commit 809faec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion android/src/main/java/com/henninghall/date_picker/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ public static Calendar isoToCalendar(String dateString, TimeZone timeZone) {
if(dateString == null) return null;
try {
Calendar calendar = Calendar.getInstance(timeZone);
calendar.setTime(getIsoUTCFormat().parse(dateString));
// Check if the string is a numeric timestamp (positive or negative)
if (dateString.matches("-?\\d+")) { // Matches both positive and negative numbers
long timestamp = Long.parseLong(dateString);
calendar.setTimeInMillis(timestamp);
} else {
calendar.setTime(getIsoUTCFormat().parse(dateString));
}
return calendar;
} catch (ParseException e) {
e.printStackTrace();
Expand Down
2 changes: 1 addition & 1 deletion src/DatePickerAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const toIsoWithTimeZoneOffset = (date) => {
/** @ts-ignore */
if (!date) return undefined
/** @ts-ignore */
return date.toISOString()
return date.getTime().toString()
}

/** @param {string} timestamp */
Expand Down

0 comments on commit 809faec

Please sign in to comment.