Skip to content

Display durations in human-readable format (N days/hours/minutes/seconds) - #11

Merged
alexec merged 5 commits into
mainfrom
copilot/simplify-duration-formatting
Nov 17, 2025
Merged

Display durations in human-readable format (N days/hours/minutes/seconds)#11
alexec merged 5 commits into
mainfrom
copilot/simplify-duration-formatting

Conversation

Copilot AI commented Nov 16, 2025

Copy link
Copy Markdown
Contributor

Duration formatting improvement - ✅ Complete

  • Create a helper function to format durations in a human-readable way (N days, N hours, N minutes, or N seconds)
  • Replace current duration formatting in main.go
  • Replace current duration formatting in mcp.go
  • Add unit tests for the new duration formatting function
  • Build and test the changes to ensure they work correctly
  • Manually verify the changes work as expected
  • Improve grammar to use singular forms (1 second, 1 minute, 1 hour, 1 day)
  • Run security checks (CodeQL - 0 alerts)
  • Final verification (all tests pass, build successful)
  • Move formatDuration to own file (duration.go)
  • Move test to own file (duration_test.go)

Summary:
Successfully implemented human-readable duration formatting that displays durations using the largest appropriate unit (days, hours, minutes, or seconds) with correct singular/plural grammar.

Code Organization:

  • duration.go: Contains the formatDuration function
  • duration_test.go: Contains comprehensive tests for formatDuration
  • Removed duplicate test from mcp_test.go

Examples:

  • Before: 15s, 135s, 3600s, 86400s
  • After: 15 seconds, 2 minutes, 1 hour, 1 day
Original prompt

Display durations using a simpler format by rounding, e.g N days, N hours, N minutes or N seconds.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 16, 2025
Copilot AI and others added 2 commits November 16, 2025 23:33
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot AI changed the title [WIP] Update duration display to use simpler format Display durations in human-readable format (N days/hours/minutes/seconds) Nov 16, 2025
Copilot AI requested a review from alexec November 16, 2025 23:38
Comment thread main.go Outdated

// formatDuration converts milliseconds to a human-readable duration string
// Returns the largest unit that makes sense: N days, N hours, N minutes, or N seconds
func formatDuration(milliseconds float64) string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot Move fun to own file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to duration.go (e30f557)

Comment thread main_test.go Outdated
)

// TestFormatDuration tests the duration formatting function
func TestFormatDuration(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot Move test too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved to duration_test.go (e30f557)

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot AI requested a review from alexec November 17, 2025 00:00
@alexec
alexec marked this pull request as ready for review November 17, 2025 00:07
@alexec
alexec enabled auto-merge (squash) November 17, 2025 00:07
@alexec
alexec merged commit 123e042 into main Nov 17, 2025
1 check passed
@alexec
alexec deleted the copilot/simplify-duration-formatting branch November 17, 2025 00:07
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