taskchampion: Add time.utc_timestamp function.
Add a function that returns a Timestamp from an i64. One advantage is improved readability since this function is guaranteed to return a `LocalResult::Single`. Anther advantage is that it will panic if something other than a LocalResult::Single is returned by chrono, which shouldn't be possible for UTC timestamps which can't have DST ambiguity.
This commit is contained in:
committed by
Dustin J. Mitchell
parent
5a4b981b6c
commit
1c4e103904
@@ -5,8 +5,7 @@ use std::convert::TryFrom;
|
||||
use std::ops::Deref;
|
||||
use std::ptr::NonNull;
|
||||
use std::str::FromStr;
|
||||
use taskchampion::chrono::{offset::LocalResult, TimeZone, Utc};
|
||||
use taskchampion::{Annotation, Tag, Task, TaskMut, Uuid};
|
||||
use taskchampion::{utc_timestamp, Annotation, Tag, Task, TaskMut, Uuid};
|
||||
|
||||
/// A task, as publicly exposed by this library.
|
||||
///
|
||||
@@ -760,9 +759,7 @@ pub unsafe extern "C" fn tc_task_remove_annotation(task: *mut TCTask, entry: i64
|
||||
wrap_mut(
|
||||
task,
|
||||
|task| {
|
||||
if let LocalResult::Single(ts) = Utc.timestamp_opt(entry, 0) {
|
||||
task.remove_annotation(ts)?;
|
||||
}
|
||||
task.remove_annotation(utc_timestamp(entry))?;
|
||||
Ok(TCResult::Ok)
|
||||
},
|
||||
TCResult::Error,
|
||||
|
||||
Reference in New Issue
Block a user