Skip to content

Commit

Permalink
feat: Add scheduled countdown (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdheepak authored May 12, 2024
2 parents 542e55c + c2df110 commit 806bb0b
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/task_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,36 @@ pub fn vague_format_date_time(from_dt: NaiveDateTime, to_dt: NaiveDateTime, with
} else {
format!("{}{}y", minus, seconds / year)
};
} else if seconds >= 60 * 60 * 24 * 90 {
}
if seconds >= 60 * 60 * 24 * 90 {
return if with_remainder {
format!("{}{}mo{}w", minus, seconds / month, (seconds - month * (seconds / month)) / week)
} else {
format!("{}{}mo", minus, seconds / month)
};
} else if seconds >= 60 * 60 * 24 * 14 {
}
if seconds >= 60 * 60 * 24 * 14 {
return if with_remainder {
format!("{}{}w{}d", minus, seconds / week, (seconds - week * (seconds / week)) / day)
} else {
format!("{}{}w", minus, seconds / week)
};
} else if seconds >= 60 * 60 * 24 {
}
if seconds >= 60 * 60 * 24 {
return if with_remainder {
format!("{}{}d{}h", minus, seconds / day, (seconds - day * (seconds / day)) / hour)
} else {
format!("{}{}d", minus, seconds / day)
};
} else if seconds >= 60 * 60 {
}
if seconds >= 60 * 60 {
return if with_remainder {
format!("{}{}h{}min", minus, seconds / hour, (seconds - hour * (seconds / hour)) / minute)
} else {
format!("{}{}h", minus, seconds / hour)
};
} else if seconds >= 60 {
}
if seconds >= 60 {
return if with_remainder {
format!("{}{}min{}s", minus, seconds / minute, (seconds - minute * (seconds / minute)))
} else {
Expand Down Expand Up @@ -263,6 +268,14 @@ impl TaskReportTable {
),
None => "".to_string(),
},
"scheduled.countdown" => match task.scheduled() {
Some(v) => vague_format_date_time(
Local::now().naive_utc(),
NaiveDateTime::new(v.date(), v.time()),
self.date_time_vague_precise,
),
None => "".to_string(),
},
"due.relative" => match task.due() {
Some(v) => vague_format_date_time(
Local::now().naive_utc(),
Expand Down

0 comments on commit 806bb0b

Please sign in to comment.