greg 0.1.2

WIP: datetime library
Documentation
use std::time;
use std::ops::{
	Add,
	Sub
};

use super::{
	Point,
	Span
};

// Constructors
impl Point {
	/// Same as constructing `Point {timestamp}` directly
	pub const fn from_epoch(timestamp: i64) -> Self {
		Self {timestamp}
	}

	/// Get the current [`Point`] in time from the system clock
	pub fn now() -> Self {
		let sys = time::SystemTime::now();
		let timestamp = match sys.duration_since(time::UNIX_EPOCH) {
			Ok(duration) => duration.as_secs() as i64,
			Err(err) => -(err.duration().as_secs() as i64)
		};
		Self {timestamp}
	}
}

// Math
impl Add<Span> for Point {
	type Output = Self;
	fn add(self, rhs: Span) -> Self::Output {
		let timestamp = self.timestamp + rhs.seconds as i64;
		Self {timestamp}
	}
}

impl Sub<Span> for Point {
	type Output = Self;
	fn sub(self, rhs: Span) -> Self::Output {
		let timestamp = self.timestamp - rhs.seconds as i64;
		Self {timestamp}
	}
}

impl Sub<Point> for Point {
	type Output = Span;
	fn sub(self, rhs: Point) -> Self::Output {
		let seconds = self.timestamp.abs_diff(rhs.timestamp);
		Span {seconds}
	}
}