Skip to content

fix: clamp Time millisecond to a valid maximum of 999#10289

Open
spokodev wants to merge 2 commits into
adobe:mainfrom
spokodev:w33/rs-constraintime-ms
Open

fix: clamp Time millisecond to a valid maximum of 999#10289
spokodev wants to merge 2 commits into
adobe:mainfrom
spokodev:w33/rs-constraintime-ms

Conversation

@spokodev

@spokodev spokodev commented Jul 2, 2026

Copy link
Copy Markdown

constrainTime clamps the millisecond field with
Math.max(0, Math.min(time.millisecond, 1000)), but a valid millisecond is in
the range 0 to 999. An out of range value is clamped to 1000, which is not a
representable millisecond.

constrainTime runs in the Time constructor, in .set({millisecond}), and in
copy(). So new Time(1, 2, 3, 5000).millisecond returns 1000, and
new Time(1, 2, 3, 5000).toString() returns "01:02:03" with the fraction
silently dropped, because the string builder computes String(1000 / 1000).

The fix clamps to 999, matching the sibling clamps in the same function
(seconds to 59, minutes to 59, hours to 23) and cycleTime, which already bounds
the millisecond with 0 to 999.

@snowystinger snowystinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR, added a few more tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants