Skip to content

sleep hour format updated to HH:MM#766

Merged
CodeWithCJ merged 4 commits intomainfrom
dev
Feb 27, 2026
Merged

sleep hour format updated to HH:MM#766
CodeWithCJ merged 4 commits intomainfrom
dev

Conversation

@CodeWithCJ
Copy link
Owner

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the user experience by standardizing how sleep-related durations are displayed throughout the application. By implementing a new 'HH:MM' formatting utility and integrating it across various components, users will now see consistent and easily understandable time representations for sleep duration, time asleep, and sleep debt, moving away from less intuitive decimal hour formats.

Highlights

  • New Time Formatting Utility: Introduced a new utility function, formatSecondsToHHMM, to consistently convert total seconds into a 'HH:MM' string format, including handling negative durations.
  • Standardized Sleep Duration Display: Updated all relevant UI components across sleep entry, timeline, analytics charts, tables, and reports to display sleep durations, time asleep, and sleep debt in the new 'HH:MM' format instead of decimal hours.
  • Improved Readability in Reports: Enhanced the readability of sleep analytics and science reports by applying the 'HH:MM' format to chart axes, tooltips, table cells, and CSV exports, providing a more intuitive representation of time.
Changelog
  • SparkyFitnessFrontend/src/pages/CheckIn/SleepEntrySection.tsx
    • Imported the new formatSecondsToHHMM utility.
    • Replaced the previous custom duration formatting logic with formatSecondsToHHMM for sleep stage durations.
    • Applied formatSecondsToHHMM to display total duration and time asleep for sleep entries.
    • Modified the data structure passed to SleepTimelineEditor to include timeAsleep in the new format.
  • SparkyFitnessFrontend/src/pages/CheckIn/SleepTimelineEditor.tsx
    • Updated the SleepTimelineEditorProps interface to include an optional timeAsleep property.
    • Adjusted the display of sleep duration to remove the 'hours' suffix, relying on the HH:MM format.
    • Added conditional rendering to display the timeAsleep value if available.
  • SparkyFitnessFrontend/src/pages/Reports/SleepAnalyticsCharts.tsx
    • Imported the formatSecondsToHHMM utility.
    • Configured the YAxis tick formatter to display values in 'HH:MM' format.
    • Updated the Tooltip formatter to present duration values in 'HH:MM' format.
  • SparkyFitnessFrontend/src/pages/Reports/SleepAnalyticsTable.tsx
    • Imported the formatSecondsToHHMM utility.
    • Refactored the calculation and display of totalSleepDuration and timeAsleep to use formatSecondsToHHMM.
    • Applied formatSecondsToHHMM to the sleepDebt display in table cells.
  • SparkyFitnessFrontend/src/pages/Reports/SleepReport.tsx
    • Imported the formatSecondsToHHMM utility.
    • Updated CSV export headers for duration, time asleep, and sleep debt to reflect the new 'HH:MM' format by removing the '(h)' suffix.
    • Applied formatSecondsToHHMM to the values exported in the CSV for duration, time asleep, and sleep debt.
  • SparkyFitnessFrontend/src/pages/Reports/SleepScience/SleepDebtBreakdown.tsx
    • Imported the formatSecondsToHHMM utility.
    • Applied formatSecondsToHHMM to the display of Total Sleep Time (TST) and sleep deviation values.
  • SparkyFitnessFrontend/src/pages/Reports/SleepScience/SleepDebtHistory.tsx
    • Imported the formatSecondsToHHMM utility.
    • Updated the YAxis tick formatter to display sleep debt values in 'HH:MM' format.
    • Applied formatSecondsToHHMM to the Tooltip formatter for deviation and surplus values.
  • SparkyFitnessFrontend/src/pages/Reports/SleepScience/SleepDebtRing.tsx
    • Imported the formatSecondsToHHMM utility.
    • Applied formatSecondsToHHMM to the display of currentDebt in the sleep debt ring chart.
  • SparkyFitnessFrontend/src/pages/Reports/SleepScience/SleepNeedBreakdown.tsx
    • Imported the formatSecondsToHHMM utility.
    • Applied formatSecondsToHHMM to the display of totalNeed.
    • Updated the YAxis tick formatter to display sleep need values in 'HH:MM' format.
    • Applied formatSecondsToHHMM to the Tooltip formatter for sleep need values.
  • SparkyFitnessFrontend/src/utils/timeFormatters.ts
    • Added a new exported function formatSecondsToHHMM which converts a total number of seconds into a 'HH:MM' string, correctly handling negative values and padding single-digit hours/minutes with a leading zero.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully standardizes the display of sleep durations to an HH:MM format across the application, which improves consistency. This is achieved by introducing a new formatSecondsToHHMM utility function. My review includes one suggestion to refine this new function to round durations to the nearest minute instead of truncating them. This change would better align with the previous behavior and provide a more accurate representation for users.

Comment on lines +11 to +18
export const formatSecondsToHHMM = (totalSeconds: number): string => {
const isNegative = totalSeconds < 0;
const absSeconds = Math.abs(totalSeconds);
const hours = Math.floor(absSeconds / 3600);
const minutes = Math.floor((absSeconds % 3600) / 60);
const formatted = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
return isNegative ? `-${formatted}` : formatted;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The current implementation of formatSecondsToHHMM uses Math.floor to calculate minutes, which truncates any remaining seconds. For example, a duration of 59 seconds would be displayed as "00:00". The previous formatting logic rounded to the nearest minute (e.g., 59 seconds was displayed as "1m"). To provide a more accurate and user-friendly duration, and to align with the previous rounding behavior, it would be better to round the total seconds to the nearest minute before calculating hours and minutes.

Suggested change
export const formatSecondsToHHMM = (totalSeconds: number): string => {
const isNegative = totalSeconds < 0;
const absSeconds = Math.abs(totalSeconds);
const hours = Math.floor(absSeconds / 3600);
const minutes = Math.floor((absSeconds % 3600) / 60);
const formatted = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
return isNegative ? `-${formatted}` : formatted;
};
export const formatSecondsToHHMM = (totalSeconds: number): string => {
const isNegative = totalSeconds < 0;
const absSeconds = Math.abs(totalSeconds);
const totalMinutes = Math.round(absSeconds / 60);
const hours = Math.floor(totalMinutes / 60);
const minutes = totalMinutes % 60;
const formatted = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
return isNegative ? `-${formatted}` : formatted;
};

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

@CodeWithCJ CodeWithCJ merged commit eac57c9 into main Feb 27, 2026
6 checks passed
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.

1 participant