Skip to content

T-timers refactor#71

Merged
Julusian merged 3 commits intofeat/t-timersfrom
rjmunro/t-timers
Feb 4, 2026
Merged

T-timers refactor#71
Julusian merged 3 commits intofeat/t-timersfrom
rjmunro/t-timers

Conversation

@rjmunro
Copy link
Collaborator

@rjmunro rjmunro commented Jan 30, 2026

About the Contributor

Type of Contribution

This is a Code improvement

Current Behavior

T-Timers have complexity depending on mode. startTimes that change etc.

New Behavior

T-Timer's state is now represented by a type:

export type TimerState = { paused: false, zeroTime: number }
	| { paused: true, duration: number }

When paused, there is a remaining duration (which may be negative if we are counting upwards). When running there is a time at which the timer reads 0, (which may be in the past if we are counting upwards).

This contains everything you need to calculate the time to display, regardless of mode.

currentDuration = state.paused ? state.duration : state.zeroTime - now
endTime =  state.paused ? state.duration + now : state.zeroTime

Testing

  • I have added one or more unit tests for this PR
  • I have updated the relevant unit tests
  • No unit test changes are needed for this PR

Affected areas

This affects the new T-Timers work.

Time Frame

Other Information

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

@rjmunro rjmunro changed the title Rjmunro/t timers T-timers refactor Jan 30, 2026
@rjmunro rjmunro force-pushed the rjmunro/t-timers branch 4 times, most recently from ba6703f to 6b80467 Compare February 3, 2026 15:37
Makes calculations of timing consistent for all timer types
State contains the dynamic how much time is left information . Mode contains more static information about the timer's properties etc.
@rjmunro rjmunro marked this pull request as ready for review February 3, 2026 17:27
@Julusian Julusian merged commit 9f453d6 into feat/t-timers Feb 4, 2026
64 checks passed
@rjmunro rjmunro deleted the rjmunro/t-timers branch February 4, 2026 11:23
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.

2 participants