apple-quant-core 0.2.0

Apple Quant's core library.
Documentation
use chrono::TimeDelta;

pub trait TimeDeltaExt {
	fn nanoseconds_i128(
		nanoseconds: i128,
	) -> Option<Self>
	where
		Self: Sized;
}

impl TimeDeltaExt for TimeDelta {
	fn nanoseconds_i128(
		nanoseconds: i128,
	) -> Option<Self>
	where
		Self: Sized,
	{
		let secs = i64::try_from(nanoseconds.div_euclid(1_000_000_000)).ok()?;
		let nanos = nanoseconds.rem_euclid(1_000_000_000) as u32;

		Self::new(secs, nanos)
	}
}