Skip to content

milliseconds parsed incorrectly in deserializeTime #1766

@davidboweninrupt

Description

@davidboweninrupt

Search terms you've used

I looked at all the existing issues.

Bug description

deserializeTime expects the millisecond part of the string to be exactly three characters.

Unfortunately, when it's not exactly three characters you get unexpected results. The function does not validate that the incoming string is three characters long.

To Reproduce

In the test case expectedTimeWithFractionalSeconds we supply as string with two characters that represents 420 milliseconds but the fixture checks the outcome is 42 milliseconds which is a mistake.

You see a similar problem if you use the example value of ".1337" too. In that case you get 1.337 seconds added to your time instead of 0.1337 seconds.

Minimal reproduction

Update the 42 in the fixture to be the correct 420.

Run npm test

Expected result

deserializeTime should produce the correct result with 420 milliseconds.

Actual result

deserializeTime produces the incorrect result with 42 milliseconds.

Environment

Use the unit tests for this project.

Additional information

This bug caused the xsd:dateTime sometimes displays slightly incorrectly issue over in Penny.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TriagedThis means that we've a ticket to look at this in the futurebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions