use crate::clublog::{Adif, CallsignException, CqZone, Entity, Prefix};
use chrono::{DateTime, Utc};
pub trait ClubLogQuery {
fn get_entity(&self, adif: Adif, timestamp: &DateTime<Utc>) -> Option<&Entity>;
fn get_prefix(&self, prefix: &str, timestamp: &DateTime<Utc>) -> Option<&Prefix>;
fn get_callsign_exception(
&self,
callsign: &str,
timestamp: &DateTime<Utc>,
) -> Option<&CallsignException>;
fn get_zone_exception(&self, callsign: &str, timestamp: &DateTime<Utc>) -> Option<CqZone>;
fn is_invalid_operation(&self, callsign: &str, timestamp: &DateTime<Utc>) -> bool;
}
pub fn is_in_time_window(
timestamp: &DateTime<Utc>,
start: Option<DateTime<Utc>>,
end: Option<DateTime<Utc>>,
) -> bool {
match (start, end) {
(Some(tstart), Some(tend)) => timestamp >= &tstart && timestamp <= &tend,
(Some(tstart), None) => timestamp >= &tstart,
(None, Some(tend)) => timestamp <= &tend,
(None, None) => true,
}
}