Fix timestamps with too much precision being representable
This commit is contained in:
parent
7360bf96f8
commit
cdcf80ab9a
3 changed files with 16 additions and 5 deletions
|
|
@ -16,6 +16,8 @@ Procedure when bumping the version number:
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- `api::Time::from_timestamp`
|
||||||
|
- `api::Time::as_timestamp`
|
||||||
- `bot::botrulez::full_help`
|
- `bot::botrulez::full_help`
|
||||||
- `bot::botrulez::ping`
|
- `bot::botrulez::ping`
|
||||||
- `bot::botrulez::short_help`
|
- `bot::botrulez::short_help`
|
||||||
|
|
@ -24,6 +26,7 @@ Procedure when bumping the version number:
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- **(breaking)** Switched to `jiff` from `time`
|
- **(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
|
- **(breaking)** Bumped `tokio-tungstenite` dependency from `0.18` to `0.24`. If
|
||||||
this causes a panic while using euphoxide, consider following the steps
|
this causes a panic while using euphoxide, consider following the steps
|
||||||
mentioned in the [tokio-tungstenite README]. If I'm reading the [rustls docs]
|
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
|
[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
|
[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
|
## v0.5.1 - 2024-05-20
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -403,15 +403,19 @@ impl<'de> Deserialize<'de> for Snowflake {
|
||||||
/// Time is specified as a signed 64-bit integer, giving the number of seconds
|
/// Time is specified as a signed 64-bit integer, giving the number of seconds
|
||||||
/// since the Unix Epoch.
|
/// since the Unix Epoch.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
#[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 {
|
impl Time {
|
||||||
pub fn new(time: Timestamp) -> Self {
|
pub fn from_timestamp(time: Timestamp) -> Self {
|
||||||
Self(time)
|
Self(time.as_second())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_timestamp(&self) -> Timestamp {
|
||||||
|
Timestamp::from_second(self.0).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn now() -> Self {
|
pub fn now() -> Self {
|
||||||
Self::new(Timestamp::now())
|
Self::from_timestamp(Timestamp::now())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -531,7 +531,7 @@ impl Conn {
|
||||||
self.ws.send(tungstenite::Message::Ping(ws_payload)).await?;
|
self.ws.send(tungstenite::Message::Ping(ws_payload)).await?;
|
||||||
|
|
||||||
// Send new euph ping
|
// 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_payload = Some(euph_payload);
|
||||||
self.last_euph_ping_replied_to = false;
|
self.last_euph_ping_replied_to = false;
|
||||||
let (tx, _) = oneshot::channel();
|
let (tx, _) = oneshot::channel();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue