schedule herlp Due
parent
4ca5ed4d7c
commit
fa7b537106
|
|
@ -503,6 +503,13 @@ impl Delta {
|
|||
struct Task(serde_yaml::Value);
|
||||
|
||||
impl Task {
|
||||
pub fn due(&self, after: u64) -> bool {
|
||||
match self.next_due(after) {
|
||||
Some(ts) => Delta::now_time() > ts,
|
||||
None => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn next_due(&self, after: u64) -> Option<u64> {
|
||||
match self.schedule() {
|
||||
Some(schedule) => self.parse_schedule_next(schedule, after),
|
||||
|
|
@ -585,6 +592,7 @@ mod test_task {
|
|||
let task = Task(serde_yaml::Value::String("hello world".to_string()));
|
||||
assert_eq!(None, task.schedule());
|
||||
assert_eq!(Some(1 as u64), task.next_due(100));
|
||||
assert!(task.due(100));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -594,6 +602,7 @@ mod test_task {
|
|||
let task = Task(serde_yaml::Value::Mapping(m));
|
||||
assert_eq!(Some("2006-01-02".to_string()), task.schedule());
|
||||
assert_eq!(Some(1136160000 as u64), task.next_due(100));
|
||||
assert!(task.due(100));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -603,6 +612,7 @@ mod test_task {
|
|||
let task = Task(serde_yaml::Value::Mapping(m));
|
||||
assert_eq!(Some("2036-01-02".to_string()), task.schedule());
|
||||
assert_eq!(Some(2082844800 as u64), task.next_due(100));
|
||||
assert!(!task.due(100));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -612,6 +622,7 @@ mod test_task {
|
|||
let task = Task(serde_yaml::Value::Mapping(m));
|
||||
assert_eq!(Some("2036-01-02T16".to_string()), task.schedule());
|
||||
assert_eq!(Some(2082902400 as u64), task.next_due(100));
|
||||
assert!(!task.due(100));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -621,6 +632,7 @@ mod test_task {
|
|||
let task = Task(serde_yaml::Value::Mapping(m));
|
||||
assert_eq!(Some("1h".to_string()), task.schedule());
|
||||
assert_eq!(Some(3700), task.next_due(100));
|
||||
assert!(task.due(100));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -630,6 +642,7 @@ mod test_task {
|
|||
let task = Task(serde_yaml::Value::Mapping(m));
|
||||
assert_eq!(Some("* * * * *".to_string()), task.schedule());
|
||||
assert_eq!(Some(120 as u64), task.next_due(100));
|
||||
assert!(task.due(100));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue