From 948a71eb8b3add371d893be2a88d3580300dc45b Mon Sep 17 00:00:00 2001
From: Helios <sandip.dey.tool@gmail.com>
Date: Tue, 1 Oct 2024 13:38:27 +0530
Subject: [PATCH] This is a Python daily task planner that displays a
 motivational quote on its daily task planner. It fetches a random quote from
 the ZenQuotes API with a fallback when this fails. Finish This program allows
 users to input their daily tasks, which are saved in a JSON file with the
 current date so that smooth entry of tasks and daily inspiration are ensured.

---
 daily_planner.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 daily_planner.py

diff --git a/daily_planner.py b/daily_planner.py
new file mode 100644
index 00000000..832df21d
--- /dev/null
+++ b/daily_planner.py
@@ -0,0 +1,64 @@
+
+import requests
+import json
+from datetime import datetime
+
+# Function to fetch a random motivational quote
+def fetch_quote():
+    fallback_quote = "'Stay positive, work hard, make it happen.' - Unknown"
+    url = "https://zenquotes.io/api/random"
+    
+    try:
+        response = requests.get(url, timeout=5)
+        if response.status_code == 200:
+            quote_data = response.json()
+            if len(quote_data) > 0:
+                quote = quote_data[0]
+                return f"'{quote['q']}' - {quote['a']}"
+            else:
+                return fallback_quote
+        else:
+            return fallback_quote
+    except Exception as e:
+        print(f"Error fetching quote: {e}")
+        return fallback_quote
+
+# Function to create a daily task planner
+def task_planner():
+    tasks = []
+    print("Enter your tasks for the day (type 'done' to finish):")
+    
+    while True:
+        task = input("> ")
+        if task.lower() == 'done':
+            break
+        tasks.append(task)
+    
+    return tasks
+
+# Function to save tasks to a file
+def save_tasks(date, tasks):
+    planner = {"date": date, "tasks": tasks}
+    with open(f"tasks_{date}.json", 'w') as file:
+        json.dump(planner, file, indent=4)
+
+def main():
+    today = datetime.now().strftime("%Y-%m-%d")
+    print(f"\nToday's Date: {today}")
+    
+    # Fetch and display a motivational quote
+    quote = fetch_quote()
+    print(f"\nDaily Motivation: {quote}\n")
+    
+    # Collects the tasks from the user
+    tasks = task_planner()
+    
+    # Saves the tasks to a file
+    if tasks:
+        save_tasks(today, tasks)
+        print("\nYour tasks have been saved!\n")
+    else:
+        print("No tasks to save.\n")
+
+if __name__ == "__main__":
+    main()
\ No newline at end of file