Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 1cf7456

Browse files
lblasafacebook-github-bot
authored andcommitted
Flipper Network Plugin change timestamps source
Summary: Flipper Network plugin uses timestamps for various usages e.g. start time of network requests, request duration, etc. This diff changes the origin of such timestamps. [NSDate timeIntervalSinceReferenceDate] in favour of FBMonotonicDeviceTimeGetCurrentMilliseconds(). The former uses a timestamp based on date. The latter uses the system boot time. This translates in errors when the Flipper Desktop app tries to make sense of such timestamps. This change also adds parity with the Android network plugin that uses System.currentTimeMillis(). The result is multiplied by 1000 as JavaScript expects a timestamp in millseconds. Reviewed By: fabiomassimo Differential Revision: D29029192 fbshipit-source-id: b38a4798ecf1564f5801ff3549ffeb9671fa32d6
1 parent 33d5d00 commit 1cf7456

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXUtility.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
@interface NSDate (SonarUtility)
2121

22-
+ (uint64_t)timestamp;
22+
+ (NSTimeInterval)timestamp;
23+
2324
@end
2425

2526
@interface FLEXUtility : NSObject

iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXUtility.mm

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,9 @@ + (NSNumber*)random {
110110

111111
@implementation NSDate (SonarUtility)
112112

113-
+ (uint64_t)getTimeNanoseconds {
114-
static struct mach_timebase_info tb_info = {0};
115-
static dispatch_once_t onceToken;
116-
dispatch_once(&onceToken, ^{
117-
__unused int ret = mach_timebase_info(&tb_info);
118-
assert(0 == ret);
119-
});
120-
121-
return (mach_absolute_time() * tb_info.numer) / tb_info.denom;
122-
}
123-
124-
+ (uint64_t)timestamp {
125-
const uint64_t nowNanoSeconds = [self getTimeNanoseconds];
126-
return nowNanoSeconds / 1000000;
113+
+ (NSTimeInterval)timestamp {
114+
const NSTimeInterval timestamp = [[NSDate date] timeIntervalSince1970];
115+
return timestamp * 1000;
127116
}
128117

129118
@end

0 commit comments

Comments
 (0)