use non-deprecated chrono functions
This commit is contained in:
committed by
Dustin J. Mitchell
parent
6fc78209da
commit
b963af9b4b
@@ -1,7 +1,7 @@
|
||||
//! Trait implementations for a few atomic types
|
||||
|
||||
use crate::traits::*;
|
||||
use taskchampion::chrono::prelude::*;
|
||||
use taskchampion::chrono::{offset::LocalResult, prelude::*};
|
||||
|
||||
impl PassByValue for usize {
|
||||
type RustType = usize;
|
||||
@@ -20,11 +20,12 @@ impl PassByValue for libc::time_t {
|
||||
type RustType = Option<DateTime<Utc>>;
|
||||
|
||||
unsafe fn from_ctype(self) -> Option<DateTime<Utc>> {
|
||||
if self == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(Utc.timestamp(self, 0))
|
||||
if self != 0 {
|
||||
if let LocalResult::Single(ts) = Utc.timestamp_opt(self, 0) {
|
||||
return Some(ts);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn as_ctype(arg: Option<DateTime<Utc>>) -> libc::time_t {
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::convert::TryFrom;
|
||||
use std::ops::Deref;
|
||||
use std::ptr::NonNull;
|
||||
use std::str::FromStr;
|
||||
use taskchampion::chrono::{TimeZone, Utc};
|
||||
use taskchampion::chrono::{offset::LocalResult, TimeZone, Utc};
|
||||
use taskchampion::{Annotation, Tag, Task, TaskMut, Uuid};
|
||||
|
||||
/// A task, as publicly exposed by this library.
|
||||
@@ -760,7 +760,9 @@ pub unsafe extern "C" fn tc_task_remove_annotation(task: *mut TCTask, entry: i64
|
||||
wrap_mut(
|
||||
task,
|
||||
|task| {
|
||||
task.remove_annotation(Utc.timestamp(entry, 0))?;
|
||||
if let LocalResult::Single(ts) = Utc.timestamp_opt(entry, 0) {
|
||||
task.remove_annotation(ts)?;
|
||||
}
|
||||
Ok(TCResult::Ok)
|
||||
},
|
||||
TCResult::Error,
|
||||
|
||||
Reference in New Issue
Block a user