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()`
This commit is contained in:
parent
35f787d2ae
commit
3f85a09b88
|
@ -295,7 +295,7 @@ fn ui<B: Backend>(f: &mut Frame<B>, app: &App) {
|
||||||
.map(|message| {
|
.map(|message| {
|
||||||
let content = vec![Spans::from(Span::raw(format!(
|
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.nick(),
|
||||||
message.message()
|
message.message()
|
||||||
)))];
|
)))];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use chrono::{DateTime, TimeZone, Utc};
|
use chrono::{DateTime, LocalResult, TimeZone, Utc};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
use waku_bindings::{Encoding, WakuContentTopic};
|
use waku_bindings::{Encoding, WakuContentTopic};
|
||||||
|
@ -36,7 +36,7 @@ impl Chat2Message {
|
||||||
&self.nick
|
&self.nick
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn timestamp(&self) -> DateTime<Utc> {
|
pub fn timestamp(&self) -> LocalResult<DateTime<Utc>> {
|
||||||
Utc.timestamp(self.timestamp as i64, 0)
|
Utc.timestamp_opt(self.timestamp as i64, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue