le-nn / moden-circles-ui-for-fitbit-clock-face

A clock face for fitbit
MIT License
18 stars 3 forks source link

12h time not shown correctly #4

Open blade86sam opened 2 years ago

blade86sam commented 2 years ago

When I set the time format to 12h, the 12 AM shows as 00 AM

What should be 12 PM shows as 12 AM instead. Next hour shows correctly, 1 PM


The issue with the 12PM showing as 12 AM is you're checking if the variable hours is <= 12 to show "AM". Should instead check that Hours from 0-11 show as "AM" the rest as "PM". so simply changing that to <= 11 would fix that, but you need to then handle the hour "12" (mid day) differently to make it show PM and additionally when the Hour is "00" to display it as 12 AM and not 00 AM.

since time.getHours() returns a value ranging from 0 to 23:

if(hours == 0){ timeText.text = ${zeroPad(12, "00")} : ${zeroPad(minutes, "00")} AM; } elseif(hours == 12){ timeText.text = ${zeroPad(hours, "00")} : ${zeroPad(minutes, "00")} PM; } elseif (hours <= 11){ timeText.text = ${zeroPad(hours, "00")} : ${zeroPad(minutes, "00")} AM; } else{ timeText.text = ${zeroPad(hours % 12, "00")} : ${zeroPad(minutes, "00")} PM; }

Overall this project is great and it's my go to clock! great job! :)

le-nn commented 2 years ago

Thank you for reporting the bug and the solution suggestions ! I will work and update within a few weeks.

blade86sam commented 2 years ago

Hey No problem! :)

One thing i just thought about which would also be a good idea is to not zeroPad the hours when on 12h format or perhaps make it a option in the settings menu?

For example, "1 : 00 PM" looks cleaner than "01 : 00 PM" imho and is more in line with how that format is intended to look. Could even have option for uppercase/lowercase "AM/PM" and "am/pm" - just food for thought :)

Looking forward to the update!!

Taebojo commented 1 year ago

No colour shows at all…

Taebojo commented 1 year ago

Overall, no data shows on the screen