Utils Module¶
General-purpose utility functions shared across the application.
Available Utilities¶
Time and Date (EU Format)¶
from src.shared_services.utils.time_and_date import (
current_datetime_eu,
current_date_eu,
format_date_eu,
parse_date_eu,
format_relative_time,
format_duration,
get_weekday_name,
get_month_name,
)
# Current date/time in EU format
now = current_datetime_eu() # "26.01.2026 14:30:45"
today = current_date_eu() # "26.01.2026"
# Format datetime objects
from datetime import date
formatted = format_date_eu(date(2026, 1, 26)) # "26.01.2026"
# Parse EU date strings
dt = parse_date_eu("26.01.2026") # date(2026, 1, 26)
# Relative time (German)
from datetime import datetime, timedelta
past = datetime.now() - timedelta(hours=2)
format_relative_time(past) # "vor 2 Stunden"
# Duration formatting
format_duration(3661) # "1 Std. 1 Min."
# German weekday/month names
get_weekday_name(date.today()) # "Montag"
get_month_name(1) # "Januar"
Files¶
| File | Purpose |
|---|---|
time_and_date.py |
EU date/time formatting and parsing |
Date Format Convention¶
This application uses EU date format exclusively:
| Type | Format | Example |
|---|---|---|
| Date | dd.mm.yyyy | 26.01.2026 |
| Time | HH:MM:SS | 14:30:45 |
| DateTime | dd.mm.yyyy HH:MM:SS | 26.01.2026 14:30:45 |
What Belongs Here¶
Put in utils: - General-purpose helper functions - Date/time utilities - String manipulation helpers - Common calculations
Do NOT put here:
- Module-specific utilities (stay in module's utils/)
- UI-related helpers (use custom_widgets/)
- Business logic (use modules/)