diff options
author | onielfa <[email protected]> | 2020-07-23 23:56:38 +0100 |
---|---|---|
committer | onielfa <[email protected]> | 2020-07-23 23:56:38 +0100 |
commit | 7e44bbff6d7f572f5f92b3a6b0f1d5e523379ba4 (patch) | |
tree | b80e0883bbd1bd02fa11f790c80c471a77800602 /src/app | |
parent | 242d58264df4842464e12c70297608bc0833d632 (diff) | |
parent | d7c303dda4750a432478c94b3ed41bca1352d839 (diff) |
Merge branch 'master' into feature/larger-names
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/impl_self.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index cf0e97f..a806dc5 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs | |||
@@ -128,7 +128,7 @@ impl App { | |||
128 | let completed = total - remaining; | 128 | let completed = total - remaining; |
129 | 129 | ||
130 | let timestamp = if self.view_month_offset == 0 { | 130 | let timestamp = if self.view_month_offset == 0 { |
131 | format!("{}", Local::now().date().format("%d/%b/%y"),) | 131 | format!("{}", Local::now().naive_local().date().format("%d/%b/%y"),) |
132 | } else { | 132 | } else { |
133 | let months = self.view_month_offset; | 133 | let months = self.view_month_offset; |
134 | format!("{}", format!("{} months ago", months),) | 134 | format!("{}", format!("{} months ago", months),) |
@@ -217,6 +217,12 @@ impl App { | |||
217 | match result { | 217 | match result { |
218 | Ok(c) => match c { | 218 | Ok(c) => match c { |
219 | Command::Add(name, goal, auto) => { | 219 | Command::Add(name, goal, auto) => { |
220 | if let Some(_) = self.habits.iter().find(|x| x.name() == name) { | ||
221 | self.message.set_kind(MessageKind::Error); | ||
222 | self.message | ||
223 | .set_message(format!("Habit `{}` already exist", &name)); | ||
224 | return; | ||
225 | } | ||
220 | let kind = if goal == Some(1) { "bit" } else { "count" }; | 226 | let kind = if goal == Some(1) { "bit" } else { "count" }; |
221 | if kind == "count" { | 227 | if kind == "count" { |
222 | self.add_habit(Box::new(Count::new(name, goal.unwrap_or(0), auto))); | 228 | self.add_habit(Box::new(Count::new(name, goal.unwrap_or(0), auto))); |