Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fractional millisecond conversion #274

Merged
merged 4 commits into from Jun 13, 2017

Conversation

OsvaldoRosado
Copy link
Member

Addresses #270

@KamilSzostak perhaps JS SDK should use this as well instead of rounding to integer milliseconds?

This change adds support for a variable amount of subsecond precision (min 3 digits, max 7).

@KamilSzostak
Copy link

KamilSzostak commented Jun 13, 2017

JS SDK is using the ms % 1000 approach. The code looks almost the same as in Node.js - https://github.com/Microsoft/ApplicationInsights-JS/blob/master/JavaScript/JavaScriptSDK/Util.ts#L447.

Let's make the same fix in JS SDK - microsoft/ApplicationInsights-JS#475

@@ -152,6 +152,7 @@ describe("Library/Util", () => {
test(24 * 60 * 60 * 1000, "1.00:00:00.000", "hours overflow");
test(11 * 3600000 + 11 * 60000 + 11111, "11:11:11.111", "all digits");
test(5 * 86400000 + 13 * 3600000 + 9 * 60000 + 8 * 1000 + 789, "5.13:09:08.789", "all digits with days");
test(1001.505, "00:00:01.001505", "fractional milliseconds");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add extra unit tests to check 1001.5, 1001.55 (not all precision digits) and 1001.5059 (too many digits, round up?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Added!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants