gcal-fetcher 0.1.0

Fetch events from the Google Calendar JSON API looking a given number of days ahead.
Documentation
use serde::{Deserialize, Serialize};
use chrono::{DateTime, Utc};

/// Parsed Google Calendar Event.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CalendarEvent {
    pub id: String,
    /// GCal E-Tag, changes if anything in the event gets edited -> used for change detection.
    pub etag: String,
    /// Event title
    pub summary: String,
    /// Event start time in UTC. For all-day events, midnight UTC on that date.
    pub start: DateTime<Utc>,
    /// Event end time in UTC. For all-day events, midnight UTC on the end date.
    pub end: DateTime<Utc>,
    pub description: Option<String>,
    pub is_whole_day_event: bool,
    pub location: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) enum EventTimeType {
    DateTime(DateTime<Utc>),
    Date(DateTime<Utc>),
}

impl EventTimeType {
    pub fn into_datetime(self) -> DateTime<Utc> {
        match self {
            EventTimeType::DateTime(dt) | EventTimeType::Date(dt) => dt,
        }
    }
}