Skip to content

Commit 3cd447c

Browse files
committed
Merge #537: Update dependencies
d83f8c6 refactor: deprecated function updated and unused import deleted (Mario) 4167b86 chore: bump thiserror from 1.0.57 to 1.0.58 (Mario) dcb0f59 chore: bump anyhow from 1.0.80 to 1.0.81 (Mario) 2b6654f chore: bump sqlx from 0.7.3 to 0.7.4 (Mario) c7ada2e chore: bump reqwest from 0.11.24 to 0.11.26 (Mario) a011158 chore: bump chrono from 0.4.34 to 0.4.35 (Mario) 6e6f4f7 chore: bump mio from 0.8.10 to 0.8.11 (Mario) Pull request description: Update dependencies: - chore: bump mio from 0.8.10 to 0.8.11 - bump chrono from 0.4.34 to 0.4.35 - bump reqwest from 0.11.24 to 0.11.26 - bump sqlx from 0.7.3 to 0.7.4 - bump anyhow from 1.0.80 to 1.0.81 - bump thiserror from 1.0.57 to 1.0.58 ACKs for top commit: josecelano: ACK d83f8c6 Tree-SHA512: 810b25592adf9b4854b34693ca8161cce9890daebad008cf4b3de6859ad15e1dca9d2f540993fe160a83a54cc2d823d4245f24b8cd6670b802032c22f2a247d2
2 parents 1368045 + d83f8c6 commit 3cd447c

File tree

4 files changed

+38
-57
lines changed

4 files changed

+38
-57
lines changed

Cargo.lock

+26-50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ version = "3.0.0-alpha.3-develop"
3434
opt-level = 3
3535

3636
[dependencies]
37-
anyhow = "1.0.79"
37+
anyhow = "1.0.81"
3838
argon2 = "0"
3939
async-trait = "0"
4040
axum = { version = "0", features = ["multipart"] }

src/upgrades/from_v1_0_0_to_v2_0_0/databases/sqlite_v2_0_0.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::missing_errors_doc)]
22

3-
use chrono::{DateTime, NaiveDateTime, Utc};
3+
use chrono::DateTime;
44
use serde::{Deserialize, Serialize};
55
use sqlx::sqlite::{SqlitePoolOptions, SqliteQueryResult};
66
use sqlx::{query, query_as, SqlitePool};
@@ -61,11 +61,10 @@ pub fn convert_timestamp_to_datetime(timestamp: i64) -> String {
6161
// The expected format in database is: 2022-11-04 09:53:57
6262
// MySQL uses a DATETIME column and SQLite uses a TEXT column.
6363

64-
let naive_datetime = NaiveDateTime::from_timestamp_opt(timestamp, 0).expect("Overflow of i64 seconds, very future!");
65-
let datetime_again: DateTime<Utc> = DateTime::from_naive_utc_and_offset(naive_datetime, Utc);
64+
let datetime = DateTime::from_timestamp(timestamp, 0).expect("Overflow of i64 seconds, very future!");
6665

6766
// Format without timezone
68-
datetime_again.format("%Y-%m-%d %H:%M:%S").to_string()
67+
datetime.format("%Y-%m-%d %H:%M:%S").to_string()
6968
}
7069

7170
pub struct SqliteDatabaseV2_0_0 {

src/utils/clock.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use chrono::{DateTime, Duration, Utc};
1+
use chrono::{DateTime, TimeDelta, Utc};
22

33
pub const DATETIME_FORMAT: &str = "%Y-%m-%d %H:%M:%S";
44

@@ -14,9 +14,15 @@ pub fn now() -> u64 {
1414
}
1515

1616
/// Returns the datetime some seconds ago.
17+
///
18+
/// # Panics
19+
///
20+
/// The function panics if the number of seconds passed as a parameter
21+
/// are more than `i64::MAX` / `1_000` or less than `-i64::MAX` / `1_000`.
1722
#[must_use]
1823
pub fn seconds_ago_utc(seconds: i64) -> DateTime<chrono::Utc> {
19-
Utc::now() - Duration::seconds(seconds)
24+
Utc::now()
25+
- TimeDelta::try_seconds(seconds).expect("seconds should be more than i64::MAX / 1_000 or less than -i64::MAX / 1_000")
2026
}
2127

2228
/// Returns the current time in database format.

0 commit comments

Comments
 (0)