Skip to content

Commit

Permalink
fix(opentelemetry-core): fixed timeInputToHrTime when time is Date type
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomchan-cxj committed Dec 30, 2020
1 parent 56e46f4 commit f1ee78a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/opentelemetry-core/src/common/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function timeInputToHrTime(time: api.TimeInput): api.HrTime {
return numberToHrtime(time);
}
} else if (time instanceof Date) {
return [time.getTime(), 0];
return numberToHrtime(time.getTime());
} else {
throw TypeError('Invalid input type');
}
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-core/test/common/time.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ describe('time', () => {

describe('#timeInputToHrTime', () => {
it('should convert Date hrTime', () => {
const timeInput = new Date();
const timeInput = new Date(1609297640313);
const output = timeInputToHrTime(timeInput);
assert.deepStrictEqual(output, [timeInput.getTime(), 0]);
assert.deepStrictEqual(output, [1609297640, 312999964]);
});

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

0 comments on commit f1ee78a

Please sign in to comment.