{"id":18744962,"url":"https://github.com/rkstudio585/python-alarm-clock","last_synced_at":"2025-11-22T19:30:18.323Z","repository":{"id":256885422,"uuid":"850499538","full_name":"rkstudio585/Python-Alarm-Clock","owner":"rkstudio585","description":"A Python-based alarm clock allowing users to set multiple alarms with a user-friendly 12-hour AM/PM format. Features real-time monitoring, colorful terminal output using colorama, and automatic exit after all alarms trigger. Ideal for learning basic Python concepts.","archived":false,"fork":false,"pushed_at":"2024-09-01T02:38:42.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-28T20:14:13.269Z","etag":null,"topics":["advanced-clock","advanced-programming","clock","clock-program","colourful","date","datetime","python","rk","rk-studio","terminal","time","watch"],"latest_commit_sha":null,"homepage":"https://github.com/mdriyadkhan585/Python-Alarm-Clock.git","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rkstudio585.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-01T00:18:18.000Z","updated_at":"2024-09-01T02:38:45.000Z","dependencies_parsed_at":"2024-09-13T16:23:15.072Z","dependency_job_id":"3c922b91-f5eb-4c4c-b5a4-bacd6ee1d5a6","html_url":"https://github.com/rkstudio585/Python-Alarm-Clock","commit_stats":null,"previous_names":["rkstudio585/python-alarm-clock"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkstudio585%2FPython-Alarm-Clock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkstudio585%2FPython-Alarm-Clock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkstudio585%2FPython-Alarm-Clock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkstudio585%2FPython-Alarm-Clock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rkstudio585","download_url":"https://codeload.github.com/rkstudio585/Python-Alarm-Clock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239627247,"owners_count":19670844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advanced-clock","advanced-programming","clock","clock-program","colourful","date","datetime","python","rk","rk-studio","terminal","time","watch"],"created_at":"2024-11-07T16:16:27.168Z","updated_at":"2025-11-22T19:30:15.849Z","avatar_url":"https://github.com/rkstudio585.png","language":"Python","readme":"# Python-Alarm-Clock\n---\n[In C Script](https://github.com/mdriyadkhan585/alarm-clock-C)\n![Python Alarm Clock Logo](logo.svg)\n\n---\n## Table of Contents\n- [Introduction](#introduction)\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Setting Multiple Alarms](#setting-multiple-alarms)\n- [Code Explanation](#code-explanation)\n  - [Imports and Initialization](#imports-and-initialization)\n  - [Setting Multiple Alarms](#setting-multiple-alarms-function)\n  - [Main Program Execution](#main-program-execution)\n- [Customization](#customization)\n- [Known Issues](#known-issues)\n- [Contributing](#contributing)\n\n---\n## Introduction\n\nWelcome to the Python Alarm Clock project! This simple yet functional alarm clock allows users to set multiple alarms using a friendly command-line interface (CLI). The script notifies users when the alarm time is reached, and it includes visual enhancements using color to improve readability.\n\nThis project is perfect for learning basic Python concepts such as time handling, loops, functions, and external libraries like `colorama`.\n\n---\n## Features\n\n- **Multiple Alarms**: Set as many alarms as you need.\n- **12-Hour Format**: Input alarm times in the user-friendly 12-hour format with AM/PM.\n- **Real-Time Monitoring**: Continuously displays the current time while waiting for alarms to trigger.\n- **Colorful Output**: Enhanced visual output using the `colorama` module for a more appealing interface.\n- **Automatic Exit**: The script automatically exits once all alarms have triggered.\n\n## Requirements\n\nTo run this project, you'll need:\n- Python 3.6 or higher\n- The `colorama` module (for colored output in the terminal)\n\n## Installation\n\n1. **Clone the Repository:**\n   ```bash\n   git clone https://github.com/mdriyadkhan585/Python-Alarm-Clock\n   cd Python-Alarm-Clock\n   ```\n\n2. **Install Dependencies:**\n   You can install the required `colorama` module using pip:\n   ```bash\n   pip install colorama\n   ```\n\n3. **Run the Script:**\n   ```bash\n   python alarm_clock.py\n   ```\n\n## Usage\n\n### Setting Multiple Alarms\n\n1. **Run the Script**: Start the script using your Python interpreter.\n2. **Input Alarm Times**: \n   - Enter the alarm time(s) in `HH:MM AM/PM` format when prompted.\n   - Type `'done'` to finish setting alarms.\n3. **Wait**: The script will display the current time and notify you when each alarm goes off.\n4. **Exit**: The script automatically exits after all alarms have been triggered.\n\n### Example Usage:\n```bash\n========================================\n        Python Alarm Clock\n========================================\n\nEnter the time to set an alarm (HH:MM AM/PM) or type 'done' to finish: 07:30 AM\n\nEnter the time to set an alarm (HH:MM AM/PM) or type 'done' to finish: 12:00 PM\n\nEnter the time to set an alarm (HH:MM AM/PM) or type 'done' to finish: done\n\n========================================\nAlarms set for the following times:\n- 07:30 AM\n- 12:00 PM\n========================================\n\nCurrent time: 07:29 AM | Waiting for the next alarm...\n```\n\n## Code Explanation\n\n### Imports and Initialization\n\n```python\nimport time\nfrom datetime import datetime\nfrom colorama import Fore, Style, init\n\n# Initialize colorama\ninit(autoreset=True)\n```\n- **time**: Provides functions to handle time-related tasks.\n- **datetime**: Provides functions to handle date and time.\n- **colorama**: Enables colored text output in the terminal.\n\n### Setting Multiple Alarms Function\n\n```python\ndef set_alarms(alarm_times):\n    print(f\"\\n{Fore.CYAN + '='*40}\")\n    print(Fore.CYAN + \"Alarms set for the following times:\")\n    for alarm_time in alarm_times:\n        print(Fore.GREEN + f\"- {alarm_time.strftime('%I:%M %p')}\")\n    print(Fore.CYAN + '='*40 + \"\\n\")\n\n    while True:\n        # Get the current time\n        now = datetime.now().time()\n\n        # Check if the current time matches any of the alarm times\n        for alarm_time in alarm_times:\n            if now.hour == alarm_time.hour and now.minute == alarm_time.minute:\n                print(f\"\\n\\n{Fore.YELLOW + '*'*40}\")\n                print(Fore.YELLOW + f\"**  Wake up! It's {alarm_time.strftime('%I:%M %p')}  **\")\n                print(Fore.YELLOW + '*'*40 + \"\\n\")\n                alarm_times.remove(alarm_time)  # Remove the triggered alarm from the list\n\n        # If no more alarms are left, break the loop\n        if not alarm_times:\n            print(Fore.CYAN + \"All alarms have triggered. Exiting alarm clock.\")\n            break\n\n        # Show the current time to the user\n        print(f\"\\r{Fore.MAGENTA}Current time: {now.strftime('%I:%M %p')} | Waiting for the next alarm...\", end=\"\")\n        \n        # Wait for 10 seconds before checking again\n        time.sleep(10)\n```\n- **set_alarms**: This function manages all the alarms the user has set. It continuously checks the current time against the set alarms and notifies the user when an alarm is triggered.\n\n### Main Program Execution\n\n```python\ndef get_alarm_times():\n    alarm_times = []\n    print(Fore.CYAN + '='*40)\n    print(Fore.CYAN + \"        Python Alarm Clock\")\n    print(Fore.CYAN + '='*40)\n    \n    while True:\n        alarm_time_str = input(Fore.YELLOW + \"\\nEnter the time to set an alarm (HH:MM AM/PM) or type 'done' to finish: \")\n        if alarm_time_str.lower() == 'done':\n            break\n        try:\n            alarm_time = datetime.strptime(alarm_time_str, \"%I:%M %p\").time()\n            alarm_times.append(alarm_time)\n        except ValueError:\n            print(Fore.RED + \"Invalid time format. Please use HH:MM AM/PM format.\")\n\n    return alarm_times\n\n# Get the list of alarm times from the user\nalarm_times = get_alarm_times()\n\n# Set the alarms if any are provided\nif alarm_times:\n    set_alarms(alarm_times)\nelse:\n    print(Fore.RED + \"No alarms were set.\")\n```\n- **get_alarm_times**: This function prompts the user to enter alarm times. It checks the format and stores valid alarm times in a list.\n- **Main Execution**: Combines the `get_alarm_times` and `set_alarms` functions to create a fully functioning alarm clock.\n\n## Customization\n\n- **Alarm Sound**: You can add a sound alert when the alarm goes off by using the `playsound` module or similar.\n- **Time Interval**: Modify the `time.sleep(10)` line to change how often the script checks the current time (e.g., every 5 seconds or every minute).\n- **24-Hour Format**: Adjust the time parsing and display format if you prefer the 24-hour time format.\n\n## Known Issues\n\n- **Exact Minute Trigger**: The alarm only triggers at the exact minute set. It does not account for seconds, so if you set the alarm for `07:30 AM`, it will trigger only if the script is running at `07:30:00 AM`.\n- **Terminal Compatibility**: The colored output works best in terminals that support ANSI escape sequences. Some environments might not display colors correctly.\n\n## Contributing\n\nContributions are welcome! Feel free to submit a pull request or open an issue on GitHub if you have any ideas for improvements or bug fixes.\n\n---\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frkstudio585%2Fpython-alarm-clock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frkstudio585%2Fpython-alarm-clock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frkstudio585%2Fpython-alarm-clock/lists"}