Skip to content

Commit 0b5acb5

Browse files
committed
fix another chrono deprecation by removing used fn
https://github.com/chronotope/chrono/releases/tag/v0.4.29: fixed by removing: warning: use of deprecated method `chrono::TimeZone::datetime_from_str`: use `DateTime::parse_from_str` instead --> database\src\lib.rs:57:33 | 57 | Err(_) => match Utc.datetime_from_str(date, format) { | ^^^^^^^^^^^^^^^^^
1 parent 6051780 commit 0b5acb5

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

database/src/lib.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use chrono::offset::TimeZone;
2-
use chrono::{DateTime, Datelike, Utc};
2+
use chrono::{DateTime, Utc};
33
use hashbrown::HashMap;
44
use intern::intern;
55
use serde::{Deserialize, Serialize};
@@ -51,33 +51,13 @@ impl std::str::FromStr for Date {
5151
}
5252

5353
impl Date {
54-
pub fn from_format(date: &str, format: &str) -> Result<Date, DateParseError> {
55-
match DateTime::parse_from_str(date, format) {
56-
Ok(value) => Ok(Date(value.with_timezone(&Utc))),
57-
Err(_) => match Utc.datetime_from_str(date, format) {
58-
Ok(dt) => Ok(Date(dt)),
59-
Err(err) => Err(DateParseError {
60-
input: date.to_string(),
61-
format: format.to_string(),
62-
error: err,
63-
}),
64-
},
65-
}
66-
}
67-
6854
pub fn ymd_hms(year: i32, month: u32, day: u32, h: u32, m: u32, s: u32) -> Date {
6955
Date(Utc.with_ymd_and_hms(year, month, day, h, m, s).unwrap())
7056
}
7157

7258
pub fn empty() -> Date {
7359
Date::ymd_hms(2000, 1, 1, 1, 1, 1)
7460
}
75-
76-
pub fn start_of_week(&self) -> Date {
77-
let weekday = self.0.weekday();
78-
// num_days_from_sunday is 0 for Sunday
79-
Date(self.0 - chrono::Duration::days(weekday.num_days_from_sunday() as i64))
80-
}
8161
}
8262

8363
impl fmt::Display for Date {

0 commit comments

Comments
 (0)