inrupt / inrupt/solid-client-js

milliseconds parsed incorrectly in `deserializeTime`

Open
#1,766 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Triaged
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.