inrupt / inrupt/solid-client-js
milliseconds parsed incorrectly in `deserializeTime`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 245
- Forks
- 42
- Avg merge
- 12h 49m
- Merged PRs (30d)
- 22
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/datatypes.ts at deserializeTime, then inspect the expectedTimeWithFractionalSeconds test fixture linked in the issue. Run npm test and check the behavior for the two-character fractional value and the .1337 example. Done means the fixture expects 420 milliseconds and deserializeTime produces the correct fractional-second result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100