updated calendar widget to show "today" and "tomorrow"
This commit is contained in:
@@ -936,6 +936,20 @@ data:
|
||||
# Calendar configuration - loaded from environment
|
||||
CALENDAR_ICAL_URLS = os.getenv("CALENDAR_ICAL_URLS", "") # JSON: {"name": "url", ...}
|
||||
|
||||
def _format_relative_date(dt: datetime, tz) -> str:
|
||||
"""Format date as 'Today', 'Tomorrow', or 'Mon 24' style."""
|
||||
now = datetime.now(tz)
|
||||
today = now.date()
|
||||
tomorrow = today + timedelta(days=1)
|
||||
event_date = dt.date()
|
||||
|
||||
if event_date == today:
|
||||
return "Today"
|
||||
elif event_date == tomorrow:
|
||||
return "Tomorrow"
|
||||
else:
|
||||
return dt.strftime("%b %d")
|
||||
|
||||
def _parse_ical_urls() -> dict[str, str]:
|
||||
"""Parse CALENDAR_ICAL_URLS environment variable."""
|
||||
if not CALENDAR_ICAL_URLS:
|
||||
@@ -1047,6 +1061,7 @@ data:
|
||||
"start": occ.isoformat(),
|
||||
"start_unix": int(occ.timestamp()),
|
||||
"start_date": occ.strftime("%b %d"),
|
||||
"start_date_relative": _format_relative_date(occ, tz),
|
||||
"start_time": occ.strftime("%H:%M"),
|
||||
"start_weekday": occ.strftime("%a"),
|
||||
"end": occ_end.isoformat() if occ_end else None,
|
||||
@@ -1066,6 +1081,7 @@ data:
|
||||
"start": dtstart_val.isoformat(),
|
||||
"start_unix": int(dtstart_val.timestamp()),
|
||||
"start_date": dtstart_val.strftime("%b %d"),
|
||||
"start_date_relative": _format_relative_date(dtstart_val, tz),
|
||||
"start_time": dtstart_val.strftime("%H:%M"),
|
||||
"start_weekday": dtstart_val.strftime("%a"),
|
||||
"end": dtend_val.isoformat() if dtend_val else None,
|
||||
@@ -1084,6 +1100,7 @@ data:
|
||||
"start": dtstart_val.isoformat(),
|
||||
"start_unix": int(dtstart_val.timestamp()),
|
||||
"start_date": dtstart_val.strftime("%b %d"),
|
||||
"start_date_relative": _format_relative_date(dtstart_val, tz),
|
||||
"start_time": dtstart_val.strftime("%H:%M"),
|
||||
"start_weekday": dtstart_val.strftime("%a"),
|
||||
"end": dtend_val.isoformat() if dtend_val else None,
|
||||
|
||||
@@ -929,7 +929,7 @@ data:
|
||||
{{ $isExtra := ge $i $showCount }}
|
||||
{{ $isAllDay := $e.Bool "is_all_day" }}
|
||||
{{ $title := $e.String "title" }}
|
||||
{{ $startDate := $e.String "start_date" }}
|
||||
{{ $startDate := $e.String "start_date_relative" }}
|
||||
{{ $startTime := $e.String "start_time" }}
|
||||
|
||||
<div class="cal-item{{ if $isExtra }} cal-extra cal-hidden{{ end }}">
|
||||
@@ -948,7 +948,7 @@ data:
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ if $hasMore }}
|
||||
<label class="cal-toggle cal-toggle-more" for="cal-expand-fam">Show more ({{ sub $count $showCount }} more) ▼</label>
|
||||
<label class="cal-toggle cal-toggle-more" for="cal-expand-fam">Show more ({{ sub $count $showCount }} additional) ▼</label>
|
||||
<label class="cal-toggle cal-toggle-less" for="cal-expand-fam">Show less ▲</label>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
@@ -611,7 +611,7 @@ data:
|
||||
widgets:
|
||||
# Calendar Events Widget (Órák & Családi)
|
||||
- type: custom-api
|
||||
title: Next Events
|
||||
title: Events Calendar
|
||||
cache: 5m
|
||||
url: http://glance-helper.glance-system.svc.cluster.local:8000/calendar/events
|
||||
parameters:
|
||||
@@ -695,7 +695,7 @@ data:
|
||||
{{ $isAllDay := $e.Bool "is_all_day" }}
|
||||
{{ $calendar := $e.String "calendar" }}
|
||||
{{ $title := $e.String "title" }}
|
||||
{{ $startDate := $e.String "start_date" }}
|
||||
{{ $startDate := $e.String "start_date_relative" }}
|
||||
{{ $startTime := $e.String "start_time" }}
|
||||
|
||||
<div class="cal-item{{ if $isExtra }} cal-extra cal-hidden{{ end }}">
|
||||
|
||||
Reference in New Issue
Block a user