Skip to content

Commit

Permalink
Fix date parsing for partial versions (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Nov 15, 2023
1 parent 6fe1fa3 commit ac07ac5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion daedalus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "daedalus"
version = "0.1.26"
version = "0.1.27"
authors = ["Jai A <[email protected]>"]
edition = "2018"
license = "MIT"
Expand Down
10 changes: 3 additions & 7 deletions daedalus/src/modded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{download_file, Error};
use crate::minecraft::{
Argument, ArgumentType, Library, VersionInfo, VersionType,
};
use chrono::{DateTime, Utc};
use chrono::{DateTime, TimeZone, Utc};
use serde::{Deserialize, Deserializer, Serialize};
use std::collections::HashMap;

Expand Down Expand Up @@ -38,12 +38,8 @@ where
{
let s = String::deserialize(deserializer)?;

DateTime::parse_from_rfc3339(&s)
.map(|dt| dt.with_timezone(&Utc))
.or_else(|_| {
DateTime::parse_from_str(&s, "%Y-%m-%dT%H:%M:%S%.f")
.map(|dt| dt.with_timezone(&Utc))
})
serde_json::from_str::<DateTime<Utc>>(&format!("\"{s}\""))
.or_else(|_| Utc.datetime_from_str(&s, "%Y-%m-%dT%H:%M:%S%.9f"))

Check warning on line 42 in daedalus/src/modded.rs

View workflow job for this annotation

GitHub Actions / clippy

use of deprecated method `chrono::TimeZone::datetime_from_str`: use `DateTime::parse_from_str` instead

warning: use of deprecated method `chrono::TimeZone::datetime_from_str`: use `DateTime::parse_from_str` instead --> daedalus/src/modded.rs:42:26 | 42 | .or_else(|_| Utc.datetime_from_str(&s, "%Y-%m-%dT%H:%M:%S%.9f")) | ^^^^^^^^^^^^^^^^^ | = note: `#[warn(deprecated)]` on by default
.map_err(serde::de::Error::custom)
}

Expand Down
2 changes: 1 addition & 1 deletion daedalus_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "daedalus_client"
version = "0.1.26"
version = "0.1.27"
authors = ["Jai A <[email protected]>"]
edition = "2018"

Expand Down

0 comments on commit ac07ac5

Please sign in to comment.