Skip to content

Commit 6e177e7

Browse files
authored
Merge pull request #24 from codehearts/update-crates
Update crates
2 parents 23db9f8 + 927fff7 commit 6e177e7

File tree

24 files changed

+434
-377
lines changed

24 files changed

+434
-377
lines changed

Cargo.lock

Lines changed: 73 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ license = "MIT"
1010
edition = "2021"
1111

1212
[dependencies]
13-
chrono = { version="0.4", default-features=false, features=["clock", "serde"] }
14-
config = { version="0.10", default-features=false, features=["yaml"] }
13+
config = { version="0.11", default-features=false, features=["yaml"] }
1514
diesel = { version="1.4", default-features=false, features=["sqlite"] }
1615
serde = { version="1.0", default-features=false, features=["derive", "std"] }
1716
serde_json = "1.0"
1817
structopt = "0.3"
19-
tokio = { version="0.2", default-features=false, features=["macros", "rt-threaded", "stream", "time"] }
2018
thiserror = "1.0"
19+
time = { version="0.3", default-features=false, features=["local-offset", "macros", "serde", "serde-human-readable", "std"] }
20+
tokio = { version="1.0", default-features=false, features=["macros", "rt-multi-thread", "time"] }
21+
tokio-stream = { version="0.1", default-features=false }
22+
tokio-util = { version="0.6", default-features=false, features=["time"] }
2123

2224
# Console integration
2325
colored = { version="2.0", default-features=false }

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.57.0
1+
1.64.0

src/command/reminder.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use super::{Command, Providers};
44
use crate::reminder::model::{NewReminder, UpdatedReminder};
55
use crate::Schedule;
6-
use chrono::{DateTime, Datelike, TimeZone, Utc, Weekday};
76
use structopt::StructOpt;
7+
use time::{OffsetDateTime, Weekday};
88

99
#[derive(StructOpt)]
1010
/// Commands for reminder management
@@ -104,10 +104,17 @@ impl Command for Reminder {
104104
}
105105

106106
/// Returns the start of the current week
107-
fn get_start_of_this_week() -> DateTime<Utc> {
108-
let iso_week = Utc::today().iso_week();
109-
Utc.isoywd(iso_week.year(), iso_week.week(), Weekday::Mon)
110-
.and_hms(0, 0, 0)
107+
fn get_start_of_this_week() -> OffsetDateTime {
108+
let mut today = OffsetDateTime::now_utc().date();
109+
110+
while today.weekday() != Weekday::Monday {
111+
match today.previous_day() {
112+
Some(date) => today = date,
113+
None => break,
114+
}
115+
}
116+
117+
today.midnight().assume_utc()
111118
}
112119

113120
#[cfg(test)]
@@ -116,9 +123,9 @@ mod tests {
116123
use crate::reminder::{model, provider::MockProvidable};
117124
use mockall::predicate::eq;
118125

119-
const SCHEDULE_ROADHOUSE: &str = r#"{"mon":["21:00:00"]}"#;
120-
const SCHEDULE_253: &str = r#"{"wed":["14:53:00"]}"#;
121-
const SCHEDULE_254: &str = r#"{"wed":["14:54:00"]}"#;
126+
const SCHEDULE_ROADHOUSE: &str = r#"{"Monday":["21:00:00.0"]}"#;
127+
const SCHEDULE_253: &str = r#"{"Wednesday":["14:53:00.0"]}"#;
128+
const SCHEDULE_254: &str = r#"{"Wednesday":["14:54:00.0"]}"#;
122129

123130
const ASSIGNEES_ROADHOUSE: [i32; 2] = [1, 2];
124131
const ASSIGNEES_253: [i32; 2] = [3, 4];

src/config/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use serde::Deserialize;
88
use std::collections::BTreeMap;
99

1010
/// All configurable properties of the app
11-
#[derive(Debug, Deserialize, PartialEq)]
11+
#[derive(Debug, Deserialize, Eq, PartialEq)]
1212
pub struct Config {
1313
/// Configuration for the database
1414
pub database: Database,
@@ -17,14 +17,14 @@ pub struct Config {
1717
}
1818

1919
/// All configurable database properties
20-
#[derive(Debug, Deserialize, PartialEq)]
20+
#[derive(Debug, Deserialize, Eq, PartialEq)]
2121
pub struct Database {
2222
/// Configuration for the sqlite database
2323
pub sqlite: SqliteDatabase,
2424
}
2525

2626
/// All configurable sqlite database properties
27-
#[derive(Debug, Deserialize, PartialEq)]
27+
#[derive(Debug, Deserialize, Eq, PartialEq)]
2828
pub struct SqliteDatabase {
2929
/// Path to the sqlite database
3030
pub path: String,

0 commit comments

Comments
 (0)