feat(title): add method to get planning timestamps

This commit is contained in:
PoiScript 2019-09-16 13:09:54 +08:00
parent 6fbe5a8085
commit 3a1b568743
2 changed files with 19 additions and 2 deletions

View file

@ -16,7 +16,7 @@ use nom::{
};
use crate::config::ParseConfig;
use crate::elements::{Drawer, Planning};
use crate::elements::{Drawer, Planning, Timestamp};
use crate::parsers::{line, skip_empty_lines, take_one_word};
#[cfg_attr(test, derive(PartialEq))]
@ -106,6 +106,24 @@ impl Title<'_> {
))
}
pub fn closed(&self) -> Option<&Timestamp> {
self.planning
.as_ref()
.and_then(|planning| planning.closed.as_ref())
}
pub fn scheduled(&self) -> Option<&Timestamp> {
self.planning
.as_ref()
.and_then(|planning| planning.scheduled.as_ref())
}
pub fn deadline(&self) -> Option<&Timestamp> {
self.planning
.as_ref()
.and_then(|planning| planning.deadline.as_ref())
}
pub fn into_owned(self) -> Title<'static> {
Title {
level: self.level,

View file

@ -1,6 +1,5 @@
use std::fmt;
use std::io::{Error, Write};
use std::marker::PhantomData;
use jetscii::{bytes, BytesConst};