Skip to content

Commit

Permalink
fix: support millisecond precision in NDK crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Oct 16, 2020
1 parent ede4e3d commit 3ef8c7c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bugsnag-plugin-android-ndk/src/main/jni/utils/serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,14 @@ void bsg_serialize_device(const bsg_device_info device, JSON_Object *event_obj)
json_object_dotset_number(event_obj, "device.totalMemory", device.total_memory);
json_object_dotset_boolean(event_obj, "device.jailbroken", device.jailbroken);

char report_time[sizeof "2018-10-08T12:07:09Z"];
if (device.time > 0) {
strftime(report_time, sizeof report_time, "%FT%TZ", gmtime(&device.time));
struct timeval current_time = {};
gettimeofday(&current_time, NULL);
int milliseconds = current_time.tv_usec / 1000;

char report_time[sizeof "2018-10-08T12:07:09.000Z"];
strftime(report_time, sizeof report_time, "%FT%T", gmtime(&device.time));
sprintf(report_time, "%s.%dZ", report_time, milliseconds);
json_object_dotset_string(event_obj, "device.time", report_time);
}
}
Expand Down

0 comments on commit 3ef8c7c

Please sign in to comment.