Skip to content

Commit 73b8bd0

Browse files
fix(opentelemetry-core): fixed timeInputToHrTime when time is Date type (#1784)
Co-authored-by: Daniel Dyla <[email protected]>
1 parent 0545122 commit 73b8bd0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/opentelemetry-core/src/common/time.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function timeInputToHrTime(time: api.TimeInput): api.HrTime {
8585
return numberToHrtime(time);
8686
}
8787
} else if (time instanceof Date) {
88-
return [time.getTime(), 0];
88+
return numberToHrtime(time.getTime());
8989
} else {
9090
throw TypeError('Invalid input type');
9191
}

packages/opentelemetry-core/test/common/time.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ describe('time', () => {
109109

110110
describe('#timeInputToHrTime', () => {
111111
it('should convert Date hrTime', () => {
112-
const timeInput = new Date();
112+
const timeInput = new Date(1609297640313);
113113
const output = timeInputToHrTime(timeInput);
114-
assert.deepStrictEqual(output, [timeInput.getTime(), 0]);
114+
assert.deepStrictEqual(output, [1609297640, 312999964]);
115115
});
116116

117117
it('should convert epoch milliseconds hrTime', () => {

0 commit comments

Comments
 (0)