#![allow(dead_code, unused_imports)]
use std::convert::TryInto;
use std::ops::{Add, AddAssign, Sub, SubAssign};
pub use std::time::*;
use wasm_bindgen::prelude::*;
#[cfg(not(target_arch = "wasm32"))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SystemTime(std::time::SystemTime);
#[cfg(not(target_arch = "wasm32"))]
impl SystemTime {
pub fn now() -> Self {
Self(std::time::SystemTime::now())
}
pub fn duration_since(&self, earlier: SystemTime) -> Result<Duration, SystemTimeError> {
self.0.duration_since(earlier.0)
}
}
#[cfg(not(target_arch = "wasm32"))]
pub const UNIX_EPOCH: SystemTime = SystemTime(std::time::SystemTime::UNIX_EPOCH);
#[cfg(target_arch = "wasm32")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SystemTime(u64);
#[cfg(target_arch = "wasm32")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SystemTimeError;
#[cfg(target_arch = "wasm32")]
impl SystemTime {
pub fn now() -> Self {
Self((js_sys::Date::now() * 1000.0) as u64)
}
pub fn duration_since(&self, earlier: SystemTime) -> Result<Duration, SystemTimeError> {
Ok(Duration::from_micros(self.0 - earlier.0))
}
}
#[cfg(target_arch = "wasm32")]
pub const UNIX_EPOCH: SystemTime = SystemTime(0);