DEV Community

Manan mangla
Manan mangla

Posted on

3-in-1 clock prototype.py

Title: Building a 3-in-1 Smart Clock CLI App in Python (Time, Alarm & Stopwatch)

After taking a rest day to avoid burnout, I jumped back into my daily 20–30 minute coding routine by building a practical, non-game utility: a 3-in-1 Smart Clock CLI App in Python using time and datetime.

🛠️ What It Does

  1. Current Time: Formats live system time into a clean 12-hour clock (%I:%M:%S).
  2. Alarm / Timer: Runs a 1-second polling loop (time.sleep(1)) that matches user input against live time and rings 5 times before returning to the main menu.
  3. Stopwatch: Counts elapsed seconds in real time until interrupted via Ctrl + C.

🐛 Bugs I Fixed & Known Drawbacks

  • What I Fixed: In my early drafts, I accidentally placed the alarm input() inside the while True polling loop (causing it to ask for the time every second) and tried incrementing a strftime string instead of an integer counter for the stopwatch.
  • Known Drawbacks: Because I kept this version pure without try-except or multithreading, the alarm loop blocks the menu while waiting, and stopping the stopwatch via Ctrl + C exits the entire script.

⚖️ Honest Work Split (70% Me / 30% AI)

  • 70% Me: Designing the menu dictionary, writing every line in VS Code, setting up the 5-cycle alarm loop, and structuring the stopwatch logic.
  • 30% AI Mentorship: Helping me debug strftime syntax differences between time and datetime and spotting loop-exit break placements.

repo link to get the code source[https://github.com/MANAN-FULLSTACK-DEV/PYTHON-BASICS-PRACTICE-AND-LEARNING/blob/main/3-in-1%20clock.py]

What small CLI utility tools did you build when learning Python's datetime module? Let me know in the comments! 👇

Top comments (0)