Skip to content

Commit 14f53e6

Browse files
Merge pull request #672 from DataDog/marcosaia/RUM-4808/fix-time-provider
[RUM-4808] Fix wrong baseOffset calculation in TimeProvider
2 parents 7293c15 + 4d47ac5 commit 14f53e6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/core/src/utils/time-provider/TimeProvider.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ export abstract class TimeProvider {
3636

3737
now(): number {
3838
const timestamp = this.getTimestamp();
39-
if (timestamp.reactNative == null) {
39+
40+
if (timestamp.reactNative != null && this.baseOffset === 0) {
41+
this.baseOffset = timestamp.unix - timestamp.reactNative;
42+
}
43+
44+
if (timestamp.reactNative == null || this.baseOffset === 0) {
4045
return timestamp.unix;
4146
} else {
4247
return this.baseOffset + timestamp.reactNative;

0 commit comments

Comments
 (0)