Skip to content

fix: prevent pace values from displaying 60 seconds - #24

Draft
janicduplessis wants to merge 1 commit into
mainfrom
@janic/issue-10-pace-rollover
Draft

fix: prevent pace values from displaying 60 seconds#24
janicduplessis wants to merge 1 commit into
mainfrom
@janic/issue-10-pace-rollover

Conversation

@janicduplessis

Copy link
Copy Markdown
Contributor

Description

formatPace floored the minute value before independently rounding the remaining seconds, so a remainder near 60 could render as 4:60. It now rounds the total pace seconds before splitting minutes and seconds, allowing the minute to carry normally without affecting the other formatters.

Test plan

  • node --test src/lib/format.test.mjs passes four cases covering rollover, zero padding, metric and imperial suffixes, and an unchanged normal pace.
  • Opened seeded hike Gorge Haut des Caps on a Stim-owned iOS simulator and verified its average pace on the same card before and after the fix.

Before

$ node -e "import('./src/lib/format.ts').then(({ formatPace }) => console.log(formatPace(299.6, 1000, 'metric')))"
4:60 /km

Seeded hike showing an average pace of 11:60 per kilometer

After

$ node -e "import('./src/lib/format.ts').then(({ formatPace }) => console.log(formatPace(299.6, 1000, 'metric')))"
5:00 /km

The same seeded hike showing the corrected average pace of 12:00 per kilometer

Closes #10

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.

[Hackathon demo] Prevent pace values from displaying 60 seconds

1 participant