Skip to content

Commit

Permalink
Merge pull request #2 from tyler-macinnis/develop
Browse files Browse the repository at this point in the history
1.0.2 Release
  • Loading branch information
tyler-macinnis authored Jul 29, 2024
2 parents 820cb17 + a3b820f commit 0e903b7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Security in case of vulnerabilities.

## [1.0.2] - 2024-07-28

### Added in 1.0.2

- Improved the way that "time since" is calculated.

## [1.0.1] - 2024-07-28

### Fixed in 1.0.1
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ pillow==10.4.0
pipdeptree==2.23.1
pur==7.3.2
pyinstaller==6.9.0
python-dateutil==2.9.0.post0
tkcalendar==1.6.1
26 changes: 19 additions & 7 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
from tkinter import messagebox, ttk

import customtkinter as ctk
from dateutil.relativedelta import relativedelta
from tkcalendar import DateEntry

# Constants
APP_NAME = "Time Capsule" # You can change this to any of the suggested names
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
DATES_FILE = os.path.join(SCRIPT_DIR, "important_dates.json")
DATE_FORMAT = "%m-%d-%Y" # Updated date format
VERSION = "1.0.1"
VERSION = "1.0.2"


def load_dates():
Expand All @@ -33,6 +34,20 @@ def save_dates(dates):
json.dump(dates, file, indent=4)


def calculate_time_since(start_date):
now = datetime.now()
start = datetime.strptime(start_date, DATE_FORMAT)
delta = relativedelta(now, start)
parts = []
if delta.years:
parts.append(f"{delta.years} year{'s' if delta.years > 1 else ''}")
if delta.months:
parts.append(f"{delta.months} month{'s' if delta.months > 1 else ''}")
if delta.days:
parts.append(f"{delta.days} day{'s' if delta.days > 1 else ''}")
return ", ".join(parts) or "0 days"


def add_date(event=None, date_str=None, note=None, mode="Add"):
def save_event():
event_name = event_entry.get()
Expand Down Expand Up @@ -97,11 +112,8 @@ def refresh_dates_list():
date_str = info["date"]
notes = info["notes"]
if search_text in event.lower() or search_text in notes.lower():
date = datetime.strptime(date_str, DATE_FORMAT)
days_since = (datetime.now() - date).days
dates_listbox.insert(
"", "end", values=(event, date_str, f"{days_since} days ago", notes)
)
time_since = calculate_time_since(date_str)
dates_listbox.insert("", "end", values=(event, date_str, time_since, notes))


def show_about():
Expand Down Expand Up @@ -260,7 +272,7 @@ def main():
style.theme_use("clam") # Using 'clam' as it is easily customizable

# Create and pack the Treeview
columns = ("Event", "Date", "Days Since", "Notes")
columns = ("Event", "Date", "Time Since", "Notes")
dates_listbox = ttk.Treeview(root, columns=columns, show="headings")
for col in columns:
dates_listbox.heading(
Expand Down

0 comments on commit 0e903b7

Please sign in to comment.