Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(clock): chrono rollover #9893

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
1. [A380X/FWS] Fix rounding error in Mach-based OVERSPEED warning - @flogross89 (floridude)
1. [A380X/MFD] Add ATCCOM MSG RECORD page layouts - @heclak (heclak)
1. [A380X/ND] Fixed active leg label to be left aligned - @MrJigs7 (MrJigs)
1. [Clock] Fixed chrono not rolling over to 00:00 when reaching 99:59 - @tracernz (Mike)

## 0.12.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ const getDisplayString = (seconds: number | null, running: boolean, ltsTest: boo
}

if (seconds !== null) {
const elapsedTime = seconds % Chrono.MAX_DISPLAYABLE_TIME_SECONDS;
return (
Math.floor(Math.min(seconds, Chrono.MAX_DISPLAYABLE_TIME_SECONDS) / Chrono.SECONDS_PER_MINUTE)
Math.floor(elapsedTime / Chrono.SECONDS_PER_MINUTE)
.toString()
.padStart(2, '0') +
(running ? ':' : ' ') +
Math.floor(Math.min(seconds, Chrono.MAX_DISPLAYABLE_TIME_SECONDS) % Chrono.SECONDS_PER_MINUTE)
Math.floor(elapsedTime % Chrono.SECONDS_PER_MINUTE)
.toString()
.padStart(2, '0')
);
Expand All @@ -28,7 +29,8 @@ const getDisplayString = (seconds: number | null, running: boolean, ltsTest: boo
export class Chrono extends DisplayComponent<ChronoProps> {
static readonly SECONDS_PER_MINUTE = 60;

static readonly MAX_DISPLAYABLE_TIME_SECONDS = 99 * 60 + 59; // "99:59" in seconds
/** Max time in seconds that can be displayed. The chrono displays rolls over from "99:59" to "00:00" on reaching this time. */
static readonly MAX_DISPLAYABLE_TIME_SECONDS = 99 * 60 + 59 + 1;

private readonly chronoText = Subject.create('');

Expand Down