- Introduction
- Features
- Prerequisites
- Installation
- Usage
- Code Overview
- How It Works
- Customization
- Known Issues
- Contributing
- License
The Advanced Digital Clock project is a terminal-based clock application written in Python. It displays the current date and time in a user-friendly format with 12-hour clock and AM/PM notation. This project is designed for learning, demonstration, and integration into larger applications. It features a clean and continuously updating interface and is compatible with various operating systems.
- Real-time Date and Time Display: Continuously shows the current date and time in the format
DD-MM-YYYY | HH:MM:SS AM/PM
. - 12-Hour Format: Time is displayed in a 12-hour format with AM/PM indicator.
- Clean Interface: The clock clears the screen before each update, ensuring a clear display.
- Cross-Platform Compatibility: Works on UNIX-like systems (Linux, macOS) and can be adapted for Windows.
To run this project, ensure you have the following:
- Python 3.x installed on your system.
- A terminal or command prompt to execute the script.
- For Windows users, you might need to configure your terminal to handle screen clearing commands.
Clone the repository to your local machine using git
:
git clone https://github.com/mdriyadkhan585/advanced-digital-clock
Change to the directory containing the script:
cd advanced-digital-clock
Execute the Python script using:
python digital_clock.py
The script will display the current date and time, updating every second. The display will clear and refresh to maintain a clean interface.
To exit the program, press Ctrl+C
in the terminal.
======================================
Welcome to the Digital Clock
======================================
Press Ctrl+C to exit the program.
Current Date and Time:
======================================
Date: 01-09-2024
Time: 02:23:15 PM
======================================
clear_screen()
: Clears the terminal screen for a clean update.print_welcome_message()
: Displays a welcome message and exit instructions.display_clock()
: Main function that retrieves and formats the current time, then updates the display.if __name__ == "__main__":
: Ensures thatdisplay_clock()
runs only when the script is executed directly.
- The script uses the
time
module to fetch the current local time. - It converts the time into a 12-hour format with AM/PM notation.
- The terminal screen is cleared before each update to keep the clock in the same position.
You can modify the script to suit your needs:
- Change Date and Time Format: Adjust the format in the
print()
statements to alter how the date and time are displayed. - Add Colors: Enhance the display by adding ANSI escape codes for colored text.
- Additional Features: Implement new features such as alarms or different time zones.
- Screen Clearing: The
clear_screen()
function may not work on all systems, particularly on Windows without special configuration. - Time Drift: Minor inaccuracies may occur over extended periods due to the
time.sleep()
function.
Contributions are welcome! If you have suggestions, improvements, or bug fixes, please submit a pull request or open an issue.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit them (
git commit -m 'Add feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.