mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Merge pull request #929 from TheAwiteb/bump-chrono-and-fix-deprecation-error
Bump chrono and fix deprecation error
This commit is contained in:
commit
1d02ae9fb9
3 changed files with 10 additions and 6 deletions
|
@ -72,7 +72,7 @@ takecell = "0.1"
|
||||||
take_mut = "0.2"
|
take_mut = "0.2"
|
||||||
rc-box = "1.1.1"
|
rc-box = "1.1.1"
|
||||||
never = "0.1.0"
|
never = "0.1.0"
|
||||||
chrono = { version = "0.4.19", default-features = false }
|
chrono = { version = "0.4.30", default-features = false }
|
||||||
either = "1.6.1"
|
either = "1.6.1"
|
||||||
bitflags = { version = "1.2" }
|
bitflags = { version = "1.2" }
|
||||||
|
|
||||||
|
|
|
@ -269,7 +269,7 @@ pub(crate) fn serde_timestamp<E: serde::de::Error>(
|
||||||
|
|
||||||
NaiveDateTime::from_timestamp_opt(timestamp, 0)
|
NaiveDateTime::from_timestamp_opt(timestamp, 0)
|
||||||
.ok_or_else(|| E::custom("invalid timestump"))
|
.ok_or_else(|| E::custom("invalid timestump"))
|
||||||
.map(|naive| DateTime::from_utc(naive, Utc))
|
.map(|naive| DateTime::from_naive_utc_and_offset(naive, Utc))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) mod serde_opt_date_from_unix_timestamp {
|
pub(crate) mod serde_opt_date_from_unix_timestamp {
|
||||||
|
@ -305,8 +305,10 @@ pub(crate) mod serde_opt_date_from_unix_timestamp {
|
||||||
|
|
||||||
{
|
{
|
||||||
let json = r#"{"date":1}"#;
|
let json = r#"{"date":1}"#;
|
||||||
let expected =
|
let expected = DateTime::from_naive_utc_and_offset(
|
||||||
DateTime::from_utc(chrono::NaiveDateTime::from_timestamp_opt(1, 0).unwrap(), Utc);
|
chrono::NaiveDateTime::from_timestamp_opt(1, 0).unwrap(),
|
||||||
|
Utc,
|
||||||
|
);
|
||||||
|
|
||||||
let Struct { date } = serde_json::from_str(json).unwrap();
|
let Struct { date } = serde_json::from_str(json).unwrap();
|
||||||
assert_eq!(date, Some(expected));
|
assert_eq!(date, Some(expected));
|
||||||
|
|
|
@ -395,8 +395,10 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn message() {
|
fn message() {
|
||||||
let timestamp = 1_569_518_342;
|
let timestamp = 1_569_518_342;
|
||||||
let date =
|
let date = DateTime::from_naive_utc_and_offset(
|
||||||
DateTime::from_utc(NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap(), Utc);
|
NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap(),
|
||||||
|
Utc,
|
||||||
|
);
|
||||||
|
|
||||||
let json = r#"{
|
let json = r#"{
|
||||||
"update_id":892252934,
|
"update_id":892252934,
|
||||||
|
|
Loading…
Reference in a new issue