summaryrefslogtreecommitdiff
path: root/calendar_manager.py
diff options
context:
space:
mode:
authormatin <matin.kaufmann@gmail.com>2025-09-11 16:27:13 +0200
committermatin <matin.kaufmann@gmail.com>2025-09-11 16:27:13 +0200
commitc7fc1d523a80c2eddacadab97b195cbe60ff83e0 (patch)
tree587d9d35f9fe95703324dfe58e03c6b7427244ef /calendar_manager.py
parent3489736a7ae2c2827452c0c23805becf41e1d2b9 (diff)
added commentary field. removed display of corrected start / end dates
Diffstat (limited to 'calendar_manager.py')
-rw-r--r--calendar_manager.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/calendar_manager.py b/calendar_manager.py
index b62cf5d..318eb83 100644
--- a/calendar_manager.py
+++ b/calendar_manager.py
@@ -4,7 +4,7 @@ import uuid
from datetime import datetime
class CalendarEntry:
- def __init__(self, start_date, end_date, keyword, entry_id=None, corrected_start_date=None, corrected_end_date=None):
+ def __init__(self, start_date, end_date, keyword, entry_id=None, corrected_start_date=None, corrected_end_date=None, commentary: str = ""):
self.id = entry_id if entry_id else str(uuid.uuid4())
# Convert string dates to datetime if necessary
self.start_date = (
@@ -19,7 +19,8 @@ class CalendarEntry:
)
self.keyword = keyword
self.corrected_start_date = corrected_start_date
- self.corrected_end_date = corrected_end_date
+ self.corrected_end_date = corrected_end_date
+ self.commentary = commentary
def to_dict(self):
return {
'id': self.id,
@@ -27,7 +28,8 @@ class CalendarEntry:
'end_date': self.end_date.isoformat(),
'keyword': self.keyword,
'corrected_start_date': self.corrected_start_date.isoformat() if self.corrected_start_date else None,
- 'corrected_end_date': self.corrected_end_date.isoformat() if self.corrected_end_date else None,
+ 'corrected_end_date': self.corrected_end_date.isoformat() if self.corrected_end_date else None,
+ 'commentary': self.commentary,
}
@classmethod
@@ -39,6 +41,7 @@ class CalendarEntry:
entry_id=data['id'],
corrected_start_date=datetime.fromisoformat(data['corrected_start_date']) if data.get('corrected_start_date') else None,
corrected_end_date=datetime.fromisoformat(data['corrected_end_date']) if data.get('corrected_end_date') else None,
+ commentary=data.get('commentary', ""),
)
def __repr__(self):
@@ -88,14 +91,14 @@ class CalendarManager:
except Exception as e:
print(f"Error writing to file {self.filename}: {e}")
- def add_entry(self, start_date, end_date, keyword):
+ def add_entry(self, start_date, end_date, keyword, commentary: str = ""):
"""Add a new event to the calendar."""
- new_entry = CalendarEntry(start_date, end_date, keyword)
+ new_entry = CalendarEntry(start_date, end_date, keyword, commentary=commentary)
self.entries.append(new_entry)
self.save_entries()
return new_entry
- def modify_entry(self, entry_id, start_date=None, end_date=None, keyword=None):
+ def modify_entry(self, entry_id, start_date=None, end_date=None, keyword=None, commentary=None):
"""Modify an existing event by ID."""
entry = self.get_entry_by_id(entry_id)
if entry:
@@ -105,6 +108,8 @@ class CalendarManager:
entry.end_date = end_date
if keyword:
entry.keyword = keyword
+ if commentary is not None:
+ entry.commentary = commentary
self.save_entries()
return entry
return None