From 3f85a09b88a9dd3cef1fd6fdb7cc88b1d4d8a948 Mon Sep 17 00:00:00 2001 From: Felicio Mununga Date: Thu, 1 Dec 2022 16:28:19 +0100 Subject: [PATCH] Replace deprecated `chrono::TimeZone::timestamp` for `timestamp_opt` in examples (#27) * Replace deprecated `chrono::TimeZone::timestamp` for `timestamp_opt` in examples * Use `.unwrap()` * Use `expect` * Use `LocalResult` for `Chat2Message.timestamp` * Use `unwrap()` in `format()` --- examples/toy-chat/src/main.rs | 2 +- examples/toy-chat/src/protocol.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/toy-chat/src/main.rs b/examples/toy-chat/src/main.rs index 887c6fc..e72c7c6 100644 --- a/examples/toy-chat/src/main.rs +++ b/examples/toy-chat/src/main.rs @@ -295,7 +295,7 @@ fn ui(f: &mut Frame, app: &App) { .map(|message| { let content = vec![Spans::from(Span::raw(format!( "[{} - {}]: {}", - message.timestamp().format("%d-%m-%y %H:%M"), + message.timestamp().unwrap().format("%d-%m-%y %H:%M"), message.nick(), message.message() )))]; diff --git a/examples/toy-chat/src/protocol.rs b/examples/toy-chat/src/protocol.rs index 4158f06..673132f 100644 --- a/examples/toy-chat/src/protocol.rs +++ b/examples/toy-chat/src/protocol.rs @@ -1,4 +1,4 @@ -use chrono::{DateTime, TimeZone, Utc}; +use chrono::{DateTime, LocalResult, TimeZone, Utc}; use once_cell::sync::Lazy; use prost::Message; use waku_bindings::{Encoding, WakuContentTopic}; @@ -36,7 +36,7 @@ impl Chat2Message { &self.nick } - pub fn timestamp(&self) -> DateTime { - Utc.timestamp(self.timestamp as i64, 0) + pub fn timestamp(&self) -> LocalResult> { + Utc.timestamp_opt(self.timestamp as i64, 0) } }