Add TimeTracking::get_timetrack_tag()
This commit is contained in:
parent
58047d319a
commit
b88e95f881
1 changed files with 13 additions and 0 deletions
|
@ -29,6 +29,7 @@ use chrono::naive::datetime::NaiveDateTime;
|
||||||
use libimagstore::store::Entry;
|
use libimagstore::store::Entry;
|
||||||
use libimagerror::into::IntoError;
|
use libimagerror::into::IntoError;
|
||||||
|
|
||||||
|
use tag::TimeTrackingTag as TTT;
|
||||||
use error::TimeTrackErrorKind as TTEK;
|
use error::TimeTrackErrorKind as TTEK;
|
||||||
use error::MapErrInto;
|
use error::MapErrInto;
|
||||||
use result::Result;
|
use result::Result;
|
||||||
|
@ -41,6 +42,8 @@ use toml_query::read::TomlValueReadExt;
|
||||||
|
|
||||||
pub trait TimeTracking {
|
pub trait TimeTracking {
|
||||||
|
|
||||||
|
fn get_timetrack_tag(&self) -> Result<TTT>;
|
||||||
|
|
||||||
fn set_start_datetime(&mut self, dt: NaiveDateTime) -> Result<()>;
|
fn set_start_datetime(&mut self, dt: NaiveDateTime) -> Result<()>;
|
||||||
|
|
||||||
fn get_start_datetime(&self) -> Result<Option<NaiveDateTime>>;
|
fn get_start_datetime(&self) -> Result<Option<NaiveDateTime>>;
|
||||||
|
@ -59,6 +62,16 @@ pub trait TimeTracking {
|
||||||
|
|
||||||
impl TimeTracking for Entry {
|
impl TimeTracking for Entry {
|
||||||
|
|
||||||
|
fn get_timetrack_tag(&self) -> Result<TTT> {
|
||||||
|
self.get_header()
|
||||||
|
.read(DATE_TIME_TAG_HEADER_PATH)
|
||||||
|
.map_err_into(TTEK::HeaderReadError)
|
||||||
|
.map(|value| match value {
|
||||||
|
Some(&Value::String(ref s)) => s.clone().into(),
|
||||||
|
_ => unimplemented!(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn set_start_datetime(&mut self, dt: NaiveDateTime) -> Result<()> {
|
fn set_start_datetime(&mut self, dt: NaiveDateTime) -> Result<()> {
|
||||||
let s = dt.format(DATE_TIME_FORMAT).to_string();
|
let s = dt.format(DATE_TIME_FORMAT).to_string();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue