#pragma once

#include <ctime>
#include <string>

// Minimal "next event" record for InfoCube
struct CalendarEvent {
  std::string title;
  std::time_t start = 0;
  std::time_t end = 0;
  bool all_day = false;

  // Preformatted for display (optional). Fetch/parse fills these.
  std::string when;

  std::time_t fetched_at = 0;
  bool ok = false;
};

// Fetch Google Calendar ICS feed and pick the next relevant event.
// url should be the "secret address in iCal format" from Google Calendar.
bool FetchCalendarICS(const std::string &url, CalendarEvent *out);

// Cache helpers.
bool LoadCalendarCache(const std::string &path, CalendarEvent *out);
bool SaveCalendarCache(const std::string &path, const CalendarEvent &ev);
