wes d2a2ba9e15 first commit 4 年之前
..
README.md d2a2ba9e15 first commit 4 年之前
code.cpp d2a2ba9e15 first commit 4 年之前
unitTest.cpp d2a2ba9e15 first commit 4 年之前

README.md

24-Hour Time

by Matt tags: strings, numbers, dates

Summary

Write a function that receives the time in 12-hour AM/PM format and returns a string representation of the time in military (24-hour) format. Examples convertTime(“07:05:45PM”) ➞ “19:05:45” convertTime(“12:40:22AM”) ➞ “00:40:22” convertTime(“12:45:54PM”) ➞ “12:45:54” Notes Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock. Noon is

Instructions

Write a function that receives the time in 12-hour AM/PM format and returns a string representation of the time in military (24-hour) format.

Examples

convertTime(“07:05:45PM”) ➞ “19:05:45”

convertTime(“12:40:22AM”) ➞ “00:40:22”

convertTime(“12:45:54PM”) ➞ “12:45:54”

Notes

  • Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock.
  • Noon is 12:00:00PM on a 12-hour clock, and 12:00:00 on a 24-hour clock.