From ea2cfa4bea295d47b9b51ba251a8062ad7d1d220 Mon Sep 17 00:00:00 2001 From: Pierre de Lacroix Date: Mon, 29 Jun 2026 16:03:00 +0200 Subject: [PATCH] only show future shifts --- src/command.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/command.rs b/src/command.rs index a7a942c..4d508d4 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,5 +1,5 @@ use crate::grist::{Priority, Shift}; -use chrono::{DateTime, FixedOffset, TimeZone}; +use chrono::{DateTime, FixedOffset, TimeZone, Utc}; use clap::{CommandFactory, Parser, Subcommand}; use matrix_sdk::{Client, Room}; @@ -102,7 +102,16 @@ pub async fn handle(command: impl AsRef, room: Room, client: Client) -> Res match clap.action { Action::List => { debug!("user asked for list"); - let shifts = crate::grist::list_shifts().await?; + let shifts = crate::grist::list_shifts() + .await? + .into_iter() + .filter(|shift| { + let now = Utc::now().with_timezone( + &FixedOffset::east_opt(2 * 3600).expect("failed to local time 1"), + ); + shift.start_time >= now + }) + .collect(); debug!("{:?}", shifts); send_room_msg_html(client, room, format_shifts(shifts)).await?; }