Time calculator many tests failing

Tell us what’s happening:
Describe your issue in detail here.

The AM/PM time is confusing me, especially around 12:00 and 24:00. I don’t even understand when the time should flip.

Moreover I am doing something wrong with the calculation of days. I thought using minutes for calculations was convenient to then use % 24 and % 60 for hours and minutes. But now I am not so sure anymore.

I would appreciate any hints into improving the code.

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36

Challenge: Time Calculator

Link to the challenge:

moving from 11:59 to 12:00 it changes from AM to PM or from PM to AM
so if it’s 11:59 AM the next minute is 12:00 PM
if it’s 11:59 PM the next minute is 12:00 AM

and when it changes from 11:59 PM to 12:00 AM, that is also when it changes day

the confusing part is that both am and pm start at 12 and then drop to 1. This is giving me the trouble, because converting from 12 → 24 hour clock is not simply subtract 12 for pm, because 12am ~ 00:00 and 12pm is 12:00. I hope I will get the code to work.

I know what you mean I haved the same problem, you can still use the % to calculate how many days passed and if it will be AM or PM. You just gotta ajust it a little bit for calculate the hour(more than using %), the issue is when using % 12 and this is equal to 0 you will get 0:## instead of 1:## this is called an special case and thats why you need to ajust it. I hope that helps.

pd: Im just not sure if Im allowed to give you an answer as is part of your challenge, gl.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.