aboutsummaryrefslogtreecommitdiff
path: root/src/app/impl_self.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/impl_self.rs')
-rw-r--r--src/app/impl_self.rs8
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)));