Skip to content

Manchester | 26-ITP-Sep | Salah Alsabhi | Sprint 1 | format clock edge cases - #1642

Open
salahalsabhi wants to merge 2 commits into
CodeYourFuture:mainfrom
salahalsabhi:format-clock-edge-cases
Open

salahalsabhi wants to merge 2 commits into
CodeYourFuture:mainfrom
salahalsabhi:format-clock-edge-cases

Conversation

@salahalsabhi

@salahalsabhi salahalsabhi commented Oct 4, 2026 •

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

Fixed formatAs12HourClock for edge cases (midnight, noon, non-zero minutes).
Added tests for am/pm boundaries and times that keep minutes.

@salahalsabhi salahalsabhi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 4, 2026
@salahalsabhi

Copy link
Copy Markdown
Author

Fixed formatAs12HourClock for edge cases (midnight, noon, minutes).
Added tests covering am/pm boundaries and non-zero minutes.

@cjyuan cjyuan left a comment

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.

Code looks good.

I am surprise the Validation Bot didn't complain when the PR description is empty.
Could you prepare the PR description in a format similar to the one used in this PR?


function formatAs12HourClock(time) {
const hours = Number(time.slice(0, 2));
const minutes = time.slice(3, 5);

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.

Note: The .slice() method supports negative indices, which count positions from the end of the string.
For example, str.slice(-3) returns the substring containing last three characters from str.

Comment on lines 9 to 12
let displayHour = hours % 12;
if (displayHour === 0) {
displayHour = 12;
}

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.

Optional change: Simplify code on lines 9-12 into one line of code.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 5, 2026
@salahalsabhi salahalsabhi changed the title Manchester | 26-ITP-Sep | Salah Alsabhi | Sprint 1 | format clock edge cases Manchester | 26-ITP-Sep | Salah Alsabhi | Sprint 1 | format clock edge cases #1642 Oct 6, 2026
@salahalsabhi salahalsabhi changed the title Manchester | 26-ITP-Sep | Salah Alsabhi | Sprint 1 | format clock edge cases #1642 Manchester | 26-ITP-Sep | Salah Alsabhi | Sprint 1 | format clock edge cases Oct 6, 2026
@salahalsabhi

Copy link
Copy Markdown
Author

Thanks for the review. Updated the PR description with the learners template, simplified displayHour to one line, and used slice(-2) for minutes. All 9 tests still pass.

@salahalsabhi salahalsabhi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 6, 2026
@cjyuan

cjyuan commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Excellent work!

@cjyuan cjyuan 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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 6, 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