From 32c499476154c846fd60626b996a1e3a1479da8c Mon Sep 17 00:00:00 2001 From: Prash1723 Date: Fri, 12 Jan 2024 23:14:44 +0530 Subject: [PATCH 1/2] enhanced loop and output --- Applications/Birthday Reminder/source-code.py | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/Applications/Birthday Reminder/source-code.py b/Applications/Birthday Reminder/source-code.py index c5f338f..1c89595 100644 --- a/Applications/Birthday Reminder/source-code.py +++ b/Applications/Birthday Reminder/source-code.py @@ -1,28 +1,40 @@ import datetime +import time +from rich.console import Console # Rich module + +rc = Console() # Rich Console for adding more indulging output + current_date = datetime.date.today().strftime('%Y-%m-%d') current_date_lst = current_date.split('-') bday_log = [ ('Ayushi', ('1999', '10', '19')), ('Yash', ('1999', '04', '21')), ] -add = input('To add birthday type y:').strip().lower() +add = input('To add new entry into birthday logs (y/n):').strip().lower() if add[:1] == 'y': - new = input('Add birthday in format yyyy-mm-dd:') - # print(new_lst) - name = input('Whose bday?') - date = new.split( '-' ) + new = str(input('Add birthday in format yyyy-mm-dd:')) # Convert date value to string for convenience in logging + # print(new_lst) + name = str(input('Whose bday?')) # Convert name to string for convenience in logging + date = new.split( '-' ) + bday_log.append((name, tuple(date))) - bday_log.append((name, tuple(date))) +elif add[:1] == 'n': + rc.print("Checking the logs..", style="cyan") + time.sleep(1) + for birthday in bday_log: + # current_dat[1] == birthday[1][1] this will check if current month is same as birth month and current date is same as + # birth date as per preadded log -for birthday in bday_log: - # current_dat[1] == birthday[1][1] this will check if current month is same as birth month and current date is same as - # birth date as per preadded log + if current_date_lst[1] == birthday[1][1] and current_date_lst[2] == birthday[1][2]: + age = int(current_date_lst[0]) - int(birthday[1][0]) + ordinal_suffix = {1: 'st', 2: 'nd', 3: 'rd', 11: 'th', 12: 'th', 13: 'th'}.get(age % 10 if not 10 < age <= 13 else age % 14, 'th') + rc.print(f"It's {birthday[0]}'s {age}{ordinal_suffix} Birthday :partying_face::birthday_cake:", style="green") - if current_date_lst[1] == birthday[1][1] and current_date_lst[2] == birthday[1][2]: - age = int(current_date_lst[0]) - int(birthday[1][0]) - ordinal_suffix = {1: 'st', 2: 'nd', 3: 'rd', 11: 'th', 12: 'th', 13: 'th'}.get(age % 10 if not 10 < age <= 13 else age % 14, 'th') - print(f" It's {birthday[0]}'s {age}{ordinal_suffix} Birthday") + else: + rc.print(f"{birthday[0]}'s birthday is not today :clock5:", style="yellow") +else: + rc.print("Please provide a valid input", style="red") From 512636e3719cb23a972b943876914a4479047309 Mon Sep 17 00:00:00 2001 From: Prash1723 Date: Fri, 12 Jan 2024 23:20:03 +0530 Subject: [PATCH 2/2] readme library names update --- Applications/Birthday Reminder/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Applications/Birthday Reminder/README.md b/Applications/Birthday Reminder/README.md index 1ea6ca6..53064b8 100644 --- a/Applications/Birthday Reminder/README.md +++ b/Applications/Birthday Reminder/README.md @@ -24,7 +24,7 @@ What the program does? ### Requirements * Python -* Python Libraries: `datetime` +* Python Libraries: `datetime` `time` `rich` ### Contributing