Oberfläche: Einträge im Kalender aufziehen, Filter für Keys und Aufzeichnungen, ganztägige Wochentage
- Zeitplan: Zeitraum im Kalender aufziehen öffnet ein Overlay mit allen Einstellungen, vorbelegt mit Tag und Uhrzeit; Klick auf einen Eintrag zeigt Details und Entfernen; "Neuer Eintrag" für die Tastatur - Meine Keys: widerrufene ausblenden (standardmäßig an) - Aufzeichnungen: vergangene ausblenden (standardmäßig an) - Kontingent: "Grenzen gelten" über zwei Spalten; alle Wochentage vorausgewählt - Wochentage ohne Uhrzeit gelten ganztags (Weekly::whole_days) - start.sh --demo: realistische Fristen für Aufzeichnungen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
11dbc1c781
commit
8e61b77ffa
9 files changed
+332
-89
No files matched your search
+1
-1
@@ -192,7 +192,7 @@ pub struct TimeArgs {
|
||||
/// Wochentage, z. B. "mo,mi" oder "mo-fr"
|
||||
#[arg(long, requires = "time")]
|
||||
weekly: Option<String>,
|
||||
/// Uhrzeit für --weekly, z. B. "08:00-11:15" oder über Mitternacht "22:00-02:00"
|
||||
/// Uhrzeit für --weekly, z. B. "08:00-11:15" oder über Mitternacht "22:00-02:00"; ohne: ganztags
|
||||
#[arg(long, requires = "weekly")]
|
||||
time: Option<String>,
|
||||
/// Anmerkung, z. B. die Lehrveranstaltung
|
||||
|
||||
+40
-2
@@ -157,13 +157,24 @@ fn fmt_until(ts: i64) -> String {
|
||||
}
|
||||
|
||||
impl Weekly {
|
||||
/// Ganze Tage, ohne Uhrzeit angegeben
|
||||
pub fn whole_days(days: Vec<Weekday>) -> Self {
|
||||
Weekly { days, start: NaiveTime::MIN, end: NaiveTime::MIN }
|
||||
}
|
||||
|
||||
pub fn all_day(&self) -> bool {
|
||||
self.start == self.end
|
||||
}
|
||||
|
||||
fn overnight(&self) -> bool {
|
||||
self.end < self.start
|
||||
}
|
||||
|
||||
fn contains(&self, t: DateTime<Local>) -> bool {
|
||||
let (day, time) = (t.weekday(), t.time());
|
||||
if self.overnight() {
|
||||
if self.all_day() {
|
||||
self.days.contains(&day)
|
||||
} else if self.overnight() {
|
||||
(self.days.contains(&day) && time >= self.start) || (self.days.contains(&day.pred()) && time < self.end)
|
||||
} else {
|
||||
self.days.contains(&day) && self.start <= time && time < self.end
|
||||
@@ -173,6 +184,17 @@ impl Weekly {
|
||||
/// Ende des Abschnitts, der t enthält
|
||||
fn end_after(&self, t: DateTime<Local>) -> Option<DateTime<Local>> {
|
||||
let mut date = t.date_naive();
|
||||
if self.all_day() {
|
||||
// Bis zum Beginn des ersten folgenden Tages, der nicht dazugehört
|
||||
date = date.succ_opt()?;
|
||||
for _ in 0..7 {
|
||||
if !self.days.contains(&date.weekday()) {
|
||||
break;
|
||||
}
|
||||
date = date.succ_opt()?;
|
||||
}
|
||||
return local(date.and_time(NaiveTime::MIN)).ok();
|
||||
}
|
||||
if self.overnight() && t.time() >= self.start {
|
||||
date = date.succ_opt()?;
|
||||
}
|
||||
@@ -223,7 +245,11 @@ impl TimeSpec {
|
||||
pub fn describe(&self) -> String {
|
||||
let mut parts = Vec::new();
|
||||
if let Some(w) = &self.weekly {
|
||||
parts.push(format!("wöchentlich {} {}-{}", days_str(&w.days), w.start.format("%H:%M"), w.end.format("%H:%M")));
|
||||
if w.all_day() {
|
||||
parts.push(format!("wöchentlich {} ganztags", days_str(&w.days)));
|
||||
} else {
|
||||
parts.push(format!("wöchentlich {} {}-{}", days_str(&w.days), w.start.format("%H:%M"), w.end.format("%H:%M")));
|
||||
}
|
||||
}
|
||||
match (self.from, self.until) {
|
||||
(Some(f), Some(u)) => parts.push(format!("{} bis {}", fmt_from(f), fmt_until(u))),
|
||||
@@ -411,6 +437,18 @@ mod tests {
|
||||
assert_eq!(t.current_end(at("2026-11-23 09:00")), Some(at("2026-11-23 11:15")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weekly_whole_days() {
|
||||
let w = Weekly::whole_days(parse_days("sa,so").unwrap());
|
||||
let at = |s: &str| Local.from_local_datetime(&NaiveDateTime::parse_from_str(s, "%Y-%m-%d %H:%M").unwrap()).unwrap();
|
||||
// 2026-11-21 ist ein Samstag
|
||||
assert!(w.contains(at("2026-11-21 00:00")) && w.contains(at("2026-11-22 23:59")));
|
||||
assert!(!w.contains(at("2026-11-20 23:59")) && !w.contains(at("2026-11-23 00:00")));
|
||||
assert_eq!(w.end_after(at("2026-11-21 10:00")), Some(at("2026-11-23 00:00")));
|
||||
let spec = TimeSpec { from: None, until: None, weekly: Some(w) };
|
||||
assert_eq!(spec.describe(), "wöchentlich sa,so ganztags");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weekly_over_midnight() {
|
||||
// Freitag 22:00 bis Samstag 02:00
|
||||
|
||||
@@ -82,8 +82,9 @@ impl TimeInput {
|
||||
let (start, end) = schedule::parse_time_range(time).map_err(|e| invalid(format!("{e:#}")))?;
|
||||
Some(Weekly { days: schedule::parse_days(days).map_err(|e| invalid(format!("{e:#}")))?, start, end })
|
||||
}
|
||||
(Some(days), None) => Some(Weekly::whole_days(schedule::parse_days(days).map_err(|e| invalid(format!("{e:#}")))?)),
|
||||
(None, None) => None,
|
||||
_ => return Err(invalid("Wochentage und Uhrzeit nur zusammen angeben")),
|
||||
(None, Some(_)) => return Err(invalid("zur Uhrzeit fehlen die Wochentage")),
|
||||
};
|
||||
Ok(TimeSpec { from: from.map(|t| t.timestamp()), until: until.map(|t| t.timestamp()), weekly })
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user