Nothing Special   »   [go: up one dir, main page]

0% found this document useful (0 votes)
2 views27 pages

yoginnee xcs projhect final (1)

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 27

PM SHRI JAWAHAR NAVODAYA VIDYALAYA,

GANDHINAGAR

PROJECT
“'Date & Time Utility Manager”

Submitted in the partial fulfillment of the


requirements for the AISSE CBSE Board
Examination
In
Computer Science For the Academic Year
2024-2025 Carried out by
YOGINEE THAKAR (12 B)
Under the esteemed guidance of
Mr. Alpesh Parmar
(PGT COMPUTER SCIENCE)

Your paragraph text


Certificate

This is to certify that YOGINEE THAKAR a


student of Class XII B, Roll No ___________, has
successfully completed his Computer Science
Project as prescribed by the Central Board of
Secondary Education (CBSE) during the
academic year 2024-2025.

His work has been thoroughly reviewed and


evaluated, and it meets the standards and
requirements set forth by the CBSE.

We commend YOGINEE THAKAR for his


dedication, hard work, and commitment to
academic excellence.

[Teacher in-charge]
[Internal Examiner] [External Examiner]
Subject Teacher,
Computer Science
[J.N.V.GANDHINAGAR]
Index

Acknowledgement
Key Features
Technologies Used
Database Structure
Steps to Execute
Source Code of Project and
explanation
Output Screens
Benefits
Bibliography
Acknowledgement
I would like to express my deepest gratitude to all those
who have contributed to the successful completion of this
investigatory project.

First and foremost, I am immensely grateful to my friends,


whose constant support, motivation, and assistance have
been invaluable. Your encouragement and collaborative
spirit have made this journey both enjoyable and fruitful.

A special thanks to my parents, whose unwavering belief in


my abilities and continuous encouragement provided me
with the strength and determination to carry out this
project. Your love and support have been the cornerstone of
my success.

I would also like to extend my sincere thanks to my Subject


Teacher, Mr. Alpesh Parmar (PGT COMPUTER SCIENCE),
for their expert guidance, constructive feedback, and for
providing the resources and knowledge necessary for this
project. Your mentorship has been instrumental in shaping
the direction and outcome of this work.

To everyone who has been a part of this journey, thank you


for your contributions and for believing in me. This project
would not have been possible without your support.

THANK YOU ALL

YOGINEE THAKAR 12-B


KEY FEATURES

1. Leap Year Checker: Determine whether a given


year is a leap year.
2. Current Date & Time: Display the current date
and time.
3. Day of the Week: Find the day of the week for
any date in the past or future.
4. Age Calculator: Calculate age from a given birth
date.
5. Days Between Dates: Calculate the number of
days between two dates.
6. Reminder System:
Set reminders for specific dates and times.
Check for due reminders and display them.
Log all reminder operations in a MySQL
database.
7. Log Viewer: View all operations performed, such
as reminders set or checked.
Technologies Used
1. Python: Core programming language.
2. MySQL: Database to store reminders
and operation logs.
3. Libraries:
4. datetime and calendar: For date and
time calculations.
5. mysql.connector: To connect and
interact with the MySQL database.
Database Structure
1. reminders Table:
2. id: Auto-incrementing primary key.
3. reminder_time: Date and time of the
reminder.
4. message: The reminder message.
5. logs Table:
6. id: Auto-incrementing primary key.
7. operation: Description of the action
performed.
8. timestamp: When the action occurred.
Steps to Execute
1. Setup:
Install required Python libraries: pip
install mysql-connector-python.
Ensure MySQL is installed and
accessible.
Modify database credentials (host, user,
password) in the script.
2. Run the Script:
Save the code in a .py file.
Execute the file in a Python-supported
IDE or terminal.
3. Interact:
Use the menu-driven interface to access
various features.
SOURCE CODE
import time
from datetime import datetime
import calendar
import mysql.connector

# Function to check if a year is a leap year


def is_leap_year(year):
if (year % 4 == 0 and year % 100 != 0) or (year % 400 ==
0):
return True
return False

def day_of_week(date):
# Parse the date in DD-MM-YYYY format
date_obj = datetime.strptime(date, "%d-%m-%Y")
return calendar.day_name[date_obj.weekday()]

def calculate_age(birth_date):
today = datetime.today()
birth_date_obj = datetime.strptime(birth_date, "%Y-%m-%d")
age = today.year - birth_date_obj.year
if today.month < birth_date_obj.month or (today.month ==
birth_date_obj.month and today.day < birth_date_obj.day):
age -= 1
return age

def days_between_dates(start_date, end_date):


start_date_obj = datetime.strptime(start_date, "%Y-%m-%d")
end_date_obj = datetime.strptime(end_date, "%Y-%m-%d")
delta = end_date_obj - start_date_obj
return delta.days
SOURCE CODE
def setup_database():
try:
conn = mysql.connector.connect(
host="localhost",
user="root",
password="Jnvg@6"
)
cursor = conn.cursor()
cursor.execute("CREATE DATABASE IF NOT EXISTS
datetimereminder")
conn.close()

conn = mysql.connector.connect(
host="localhost",
user="root",
password="Jnvg@6",
database="datetimereminder"
)
cursor = conn.cursor()

cursor.execute('''CREATE TABLE IF NOT EXISTS


reminders (
id INT AUTO_INCREMENT PRIMARY KEY,
reminder_time DATETIME NOT NULL,
message TEXT NOT NULL)''')

cursor.execute('''CREATE TABLE IF NOT EXISTS logs (


id INT AUTO_INCREMENT PRIMARY KEY,
operation TEXT NOT NULL,
timestamp DATETIME NOT NULL)''')

conn.commit()
conn.close()
except mysql.connector.Error as e:
print(f"Error setting up the database: {e}")
SOURCE CODE
# Log Operations
def log_operation(operation):
try:
conn = mysql.connector.connect(
host="localhost",
user="root",
password="Jnvg@6",
database="datetimereminder"
)
cursor = conn.cursor()
cursor.execute("INSERT INTO logs (operation, timestamp) VALUES (%s,
%s)", (operation, datetime.now()))
conn.commit()
conn.close()
except mysql.connector.Error as e:
print(f"Error logging operation: {e}")

# Functions for Date & Time Utilities


def get_current_time():
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")

def set_reminder(reminder_time, message):


try:
conn = mysql.connector.connect(
host="localhost",
user="root",
password="Jnvg@6",
database="datetimereminder"
)
cursor = conn.cursor()
cursor.execute("INSERT INTO reminders (reminder_time, message)
VALUES (%s, %s)", (reminder_time, message))
conn.commit()
conn.close()
print(f"Reminder set for {reminder_time}.")
log_operation(f"Reminder set for {reminder_time}: {message}")
except mysql.connector.Error as e:
print(f"Error setting reminder: {e}")
SOURCE CODE
# Check and Trigger Reminders
def check_reminders():
try:
conn = mysql.connector.connect(
host="localhost",
user="root",
password="Jnvg@6",
database="datetimereminder"
)
cursor = conn.cursor()
current_time = datetime.now().strftime("%Y-%m-%d
%H:%M:%S")
cursor.execute("SELECT id, message FROM reminders
WHERE reminder_time <= %s", (current_time,))
reminders = cursor.fetchall()

if reminders:
for reminder in reminders:
print(f"Reminder: {reminder[1]}")
cursor.execute("DELETE FROM reminders WHERE id =
%s", (reminder[0],))

conn.commit()
else:
print("No due reminders.")

conn.close()

except mysql.connector.Error as e:
print(f"Error checking reminders: {e}")
SOURCE CODE

# View Reminder Logs


def view_logs():
try:
conn = mysql.connector.connect(
host="localhost",
user="root",
password="Jnvg@6",
database="datetimereminder"
)
cursor = conn.cursor()
cursor.execute("SELECT * FROM logs")
logs = cursor.fetchall()

if logs:
print("\n===== All Logs =====")
for log in logs:
print(f"ID: {log[0]} | Operation: {log[1]} | Timestamp: {log[2]}")
else:
print("No logs found.")

conn.close()
except mysql.connector.Error as e:
print(f"Error viewing logs: {e}")
SOURCE CODE

# Main Program
if __name__ == "__main__":
setup_database()
while True:
print("\n===== Date & Time Utilities =====")
print("1. Leap Year Checker")
print("2. Current Date & Time Display")
print("3. Find Day of the Week")
print("4. Age Calculator")
print("5. Days Between Two Dates")
print("6. Set Reminder")
print("7. Check Reminders")
print("8. View Reminder Log")
print("9. Exit")
SOURCE CODE
choice = input("Enter the number of the option you want to use: ")

if choice == '1':
year = int(input("Enter a year to check if it's a leap year: "))
print(f"{year} is a leap year." if is_leap_year(year) else f"{year} is not a leap
year.")

elif choice == '2':


print("Current Date and Time:", get_current_time())

elif choice == '3':


date = input("Enter a date (DD-MM-YYYY): ")
try:
print(f"The day of the week is: {day_of_week(date)}.")
except ValueError:
print("Invalid date format. Please use DD-MM-YYYY.")

elif choice == '4':


birth_date = input("Enter your birth date (YYYY-MM-DD): ")
try:
print(f"Your age is: {calculate_age(birth_date)} years.")
except ValueError:
print("Invalid date format. Please use YYYY-MM-DD.")

elif choice == '5':


start_date = input("Enter the start date (YYYY-MM-DD): ")
end_date = input("Enter the end date (YYYY-MM-DD): ")
try:
print(f"The difference between {start_date} and {end_date} is
{days_between_dates(start_date, end_date)} days.")
except ValueError:
print("Invalid date format. Please use YYYY-MM-DD.")

elif choice == '6':


reminder_time = input("Enter the reminder time (YYYY-MM-DD HH:MM:SS):
")
message = input("Enter the reminder message: ")
try:
set_reminder(reminder_time, message)
except ValueError:
print("Invalid date and time format. Please use YYYY-MM-DD
HH:MM:SS.")
SOURCE CODE
elif choice == '7':
check_reminders()

elif choice == '8':


view_logs()

elif choice == '9':


print("Exiting the program. Goodbye!")
break

else:
print("Invalid choice. Please try again!")
SOURCE CODE
elif choice == '7':
check_reminders()

elif choice == '8':


view_logs()

elif choice == '9':


print("Exiting the program. Goodbye!")
break

else:
print("Invalid choice. Please try again!")
OUTOUT SCREENS
1. Leap Year Checker
INPUT:

OUTPUT:
OUTOUT SCREENS
2. Current Date & Time Display

INPUT:

OUTPUT:
OUTOUT SCREENS
3.Age Calculator

INPUT:

OUTPUT:
OUTOUT SCREENS
4. Set Reminder

INPUT:

OUTPUT:
OUTOUT SCREENS
5. Check Reminders

INPUT:

OUTPUT:
OUTOUT SCREENS
6. View Reminder Logs

INPUT:

OUTPUT:
Benefits
1. Combines utility tools with a
robust reminder system.
2. Simple and intuitive interface for
users.
3. Stores reminders and logs
securely in a database for future
reference.
Bibliography

1. Python Software Foundation.


Python Documentation.
https://docs.python.org/3/
2. Oracle Corporation. MySQL
Connector/Python Guide.
https://dev.mysql.com/
3. Real Python. Guide to Python
Datetime. https://realpython.com/
4. GeeksforGeeks. Python Calendar
Module.
https://www.geeksforgeeks.org/
5. All representable code snippets
are from carbon.now.sh

You might also like