diff --git a/CHANGELOG.md b/CHANGELOG.md index 54b8300..6ef9b70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ Procedure when bumping the version number: ### Added +- `api::Time::from_timestamp` +- `api::Time::as_timestamp` - `bot::botrulez::full_help` - `bot::botrulez::ping` - `bot::botrulez::short_help` @@ -24,6 +26,7 @@ Procedure when bumping the version number: ### Changed - **(breaking)** Switched to `jiff` from `time` +- **(breaking)** `api::Time` contents are now an `i64` - **(breaking)** Bumped `tokio-tungstenite` dependency from `0.18` to `0.24`. If this causes a panic while using euphoxide, consider following the steps mentioned in the [tokio-tungstenite README]. If I'm reading the [rustls docs] @@ -32,6 +35,10 @@ Procedure when bumping the version number: [tokio-tungstenite README]: https://github.com/snapview/tokio-tungstenite?tab=readme-ov-file#features [rustls docs]: https://docs.rs/rustls/0.23.19/rustls/crypto/struct.CryptoProvider.html#using-the-per-process-default-cryptoprovider +### Removed + +- `api::Time::new` + ## v0.5.1 - 2024-05-20 ### Added diff --git a/src/api/types.rs b/src/api/types.rs index 8f438e9..b1408a8 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -403,15 +403,19 @@ impl<'de> Deserialize<'de> for Snowflake { /// Time is specified as a signed 64-bit integer, giving the number of seconds /// since the Unix Epoch. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -pub struct Time(#[serde(with = "jiff::fmt::serde::timestamp::second::required")] pub Timestamp); +pub struct Time(pub i64); impl Time { - pub fn new(time: Timestamp) -> Self { - Self(time) + pub fn from_timestamp(time: Timestamp) -> Self { + Self(time.as_second()) + } + + pub fn as_timestamp(&self) -> Timestamp { + Timestamp::from_second(self.0).unwrap() } pub fn now() -> Self { - Self::new(Timestamp::now()) + Self::from_timestamp(Timestamp::now()) } } diff --git a/src/conn.rs b/src/conn.rs index 8d6820c..6d88827 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -531,7 +531,7 @@ impl Conn { self.ws.send(tungstenite::Message::Ping(ws_payload)).await?; // Send new euph ping - let euph_payload = Time::new(now); + let euph_payload = Time::from_timestamp(now); self.last_euph_ping_payload = Some(euph_payload); self.last_euph_ping_replied_to = false; let (tx, _) = oneshot::channel();