diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app/impl_self.rs | 4 | ||||
-rw-r--r-- | src/views.rs | 18 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index 744f906..2450bff 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs | |||
@@ -118,7 +118,7 @@ impl App { | |||
118 | } | 118 | } |
119 | 119 | ||
120 | pub fn status(&self) -> StatusLine { | 120 | pub fn status(&self) -> StatusLine { |
121 | let today = chrono::Local::now().naive_utc().date(); | 121 | let today = chrono::Local::now().naive_local().date(); |
122 | let remaining = self.habits.iter().map(|h| h.remaining(today)).sum::<u32>(); | 122 | let remaining = self.habits.iter().map(|h| h.remaining(today)).sum::<u32>(); |
123 | let total = self.habits.iter().map(|h| h.goal()).sum::<u32>(); | 123 | let total = self.habits.iter().map(|h| h.goal()).sum::<u32>(); |
124 | let completed = total - remaining; | 124 | let completed = total - remaining; |
@@ -207,7 +207,7 @@ impl App { | |||
207 | .iter_mut() | 207 | .iter_mut() |
208 | .find(|x| x.name() == name && x.is_auto()); | 208 | .find(|x| x.name() == name && x.is_auto()); |
209 | if let Some(h) = target_habit { | 209 | if let Some(h) = target_habit { |
210 | h.modify(Local::now().naive_utc().date(), event); | 210 | h.modify(Local::now().naive_local().date(), event); |
211 | } | 211 | } |
212 | }; | 212 | }; |
213 | match result { | 213 | match result { |
diff --git a/src/views.rs b/src/views.rs index 24c8a4d..da077ac 100644 --- a/src/views.rs +++ b/src/views.rs | |||
@@ -43,7 +43,7 @@ where | |||
43 | let strikethrough = Style::from(Effect::Strikethrough); | 43 | let strikethrough = Style::from(Effect::Strikethrough); |
44 | 44 | ||
45 | let goal_status = | 45 | let goal_status = |
46 | self.view_month_offset() == 0 && self.reached_goal(Local::now().naive_utc().date()); | 46 | self.view_month_offset() == 0 && self.reached_goal(Local::now().naive_local().date()); |
47 | 47 | ||
48 | printer.with_style( | 48 | printer.with_style( |
49 | Style::merge(&[ | 49 | Style::merge(&[ |
@@ -77,12 +77,20 @@ where | |||
77 | .collect::<Vec<_>>(); | 77 | .collect::<Vec<_>>(); |
78 | for (week, line_nr) in days.chunks(7).zip(2..) { | 78 | for (week, line_nr) in days.chunks(7).zip(2..) { |
79 | let weekly_goal = self.goal() * week.len() as u32; | 79 | let weekly_goal = self.goal() * week.len() as u32; |
80 | let is_this_week = week.contains(&Local::now().naive_utc().date()); | 80 | let is_this_week = week.contains(&Local::now().naive_local().date()); |
81 | let remaining = week.iter().map(|&i| self.remaining(i)).sum::<u32>(); | 81 | let remaining = week.iter().map(|&i| self.remaining(i)).sum::<u32>(); |
82 | let completions = weekly_goal - remaining; | 82 | let completions = weekly_goal - remaining; |
83 | let full = CONFIGURATION.view_width - 8; | 83 | let full = CONFIGURATION.view_width - 8; |
84 | let bars_to_fill = if weekly_goal > 0 {(completions * full as u32) / weekly_goal} else {0}; | 84 | let bars_to_fill = if weekly_goal > 0 { |
85 | let percentage = if weekly_goal > 0 {(completions as f64 * 100.) / weekly_goal as f64} else {0.0}; | 85 | (completions * full as u32) / weekly_goal |
86 | } else { | ||
87 | 0 | ||
88 | }; | ||
89 | let percentage = if weekly_goal > 0 { | ||
90 | (completions as f64 * 100.) / weekly_goal as f64 | ||
91 | } else { | ||
92 | 0.0 | ||
93 | }; | ||
86 | printer.with_style(future_style, |p| { | 94 | printer.with_style(future_style, |p| { |
87 | p.print((4, line_nr), &"─".repeat(full)); | 95 | p.print((4, line_nr), &"─".repeat(full)); |
88 | }); | 96 | }); |
@@ -141,7 +149,7 @@ where | |||
141 | } | 149 | } |
142 | 150 | ||
143 | fn on_event(&mut self, e: Event) -> EventResult { | 151 | fn on_event(&mut self, e: Event) -> EventResult { |
144 | let now = Local::now().naive_utc().date(); | 152 | let now = Local::now().naive_local().date(); |
145 | if self.is_auto() { | 153 | if self.is_auto() { |
146 | return EventResult::Ignored; | 154 | return EventResult::Ignored; |
147 | } | 155 | } |