fix: iCal duration parser tracks seconds, rounds up to minutes
This commit is contained in:
@@ -305,7 +305,7 @@ fn parse_duration(s: &str) -> DomainResult<u32> {
|
||||
)));
|
||||
}
|
||||
let body = &s[2..];
|
||||
let mut total_mins: u32 = 0;
|
||||
let mut total_secs: u32 = 0;
|
||||
let mut num_buf = String::new();
|
||||
|
||||
for c in body.chars() {
|
||||
@@ -317,9 +317,9 @@ fn parse_duration(s: &str) -> DomainResult<u32> {
|
||||
})?;
|
||||
num_buf.clear();
|
||||
match c {
|
||||
'H' => total_mins += n * 60,
|
||||
'M' => total_mins += n,
|
||||
'S' => total_mins += n / 60,
|
||||
'H' => total_secs += n * 3600,
|
||||
'M' => total_secs += n * 60,
|
||||
'S' => total_secs += n,
|
||||
_ => {
|
||||
return Err(crate::DomainError::validation(format!(
|
||||
"unknown DURATION unit '{c}' in: {s}"
|
||||
@@ -328,6 +328,7 @@ fn parse_duration(s: &str) -> DomainResult<u32> {
|
||||
}
|
||||
}
|
||||
}
|
||||
let total_mins = (total_secs + 59) / 60;
|
||||
if total_mins == 0 {
|
||||
return Err(crate::DomainError::validation(format!(
|
||||
"zero DURATION: {s}"
|
||||
|
||||
Reference in New Issue
Block a user