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?; }