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
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue