Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(tasks): detect fractional due times in truncation warning
  • Loading branch information
jeevan6996 committed Apr 14, 2026
commit 1271b41eb15c07c608346952acf9b7012c15fddb
44 changes: 27 additions & 17 deletions crates/google-workspace-cli/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,19 @@ fn parse_and_validate_inputs(

fn extract_due_string_with_non_midnight_time(body: &Value) -> Option<String> {
let due = body.get("due")?.as_str()?;
let time_part = due.split_once('T')?.1;
let hhmmss: String = time_part
.chars()
.take_while(|c| c.is_ascii_digit() || *c == ':')
.collect();

let mut parts = hhmmss.split(':');
let hour: u32 = parts.next()?.parse().ok()?;
let minute: u32 = parts.next()?.parse().ok()?;
let second: u32 = parts
.next()
.and_then(|s| s.split('.').next())
.and_then(|s| s.parse().ok())
.unwrap_or(0);
let (_, time_part) = due.split_once('T')?;
let time_only = match time_part.find(|c: char| c == 'Z' || c == '+' || c == '-') {
Some(idx) => &time_part[..idx],
None => time_part,
};

if hour == 0 && minute == 0 && second == 0 {
None
} else {
if time_only
.chars()
.any(|c| c.is_ascii_digit() && c != '0')
{
Some(due.to_string())
} else {
None
}
}
Comment thread
jeevan6996 marked this conversation as resolved.

Expand Down Expand Up @@ -1288,6 +1282,22 @@ mod tests {
assert!(warning.is_none());
}

#[test]
fn tasks_due_time_truncated_warning_detects_fractional_seconds() {
let doc = RestDescription {
name: "tasks".to_string(),
..Default::default()
};
let method = RestMethod {
http_method: "PATCH".to_string(),
..Default::default()
};
let body = json!({"due": "2026-04-12T00:00:00.500Z"});

let warning = tasks_due_time_truncated_warning(&doc, &method, Some(&body));
assert!(warning.is_some());
}

#[test]
fn tasks_due_time_truncated_warning_ignores_non_tasks_apis() {
let doc = RestDescription {
Expand Down
Loading