Skip to content

Cape Town | 26-ITP-Sep | Quentin Gwele | Sprint 1 | format-clock-edge-cases - #1658

Open
lwandogwele52-ui wants to merge 1 commit into
CodeYourFuture:mainfrom
lwandogwele52-ui:feature/format-clock-edge-cases
Open

lwandogwele52-ui wants to merge 1 commit into
CodeYourFuture:mainfrom
lwandogwele52-ui:feature/format-clock-edge-cases

Conversation

@lwandogwele52-ui

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1197

Changelist

  • Added tests for edge cases of formatAs12HourClock: midnight hour (00:xx), early morning, noon hour (12:xx), afternoon, and late evening
  • Fixed the function so minutes from the input are kept (previously pm times always showed ":00")
  • Fixed hours so they are always padded to two digits (e.g. "01:00 pm")
  • Fixed midnight and noon: "00:15" now returns "12:15 am" and "12:30" returns "12:30 pm"
  • All tests pass with npm test

@lwandogwele52-ui lwandogwele52-ui added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 7, 2026

@Luro91 Luro91 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done the code works correctly and the tests cover the edge cases

return `${hours - 12}:00 pm`;
}
return `${time} am`;
return `${String(hours12).padStart(2, "0")}:${minutes} ${period}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You don't need to change this. Sometimes it can be helpful to add helper variables to make the code easier to read. In this case the ${String(hours12).padStart(2, "0")} part could be extracted into another variables.

@Luro91 Luro91 added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants