diff options
author | Akshay <[email protected]> | 2020-07-23 17:53:59 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-07-23 17:53:59 +0100 |
commit | 91cb3ebf5b3af666b13f4821ff25f219fdccd7b9 (patch) | |
tree | c91d6cffd4d215b325e81bedfdcfdfdcea76a537 /src/views.rs | |
parent | 02bba52346d948e90fbc1b351486f0f1307c243d (diff) | |
parent | d1d1aeb3d5aaa75f262467c5e683e76ce7a844ab (diff) |
Merge branch 'feature/windows' of https://github.com/filalex77/dijo into feature/windows
Diffstat (limited to 'src/views.rs')
-rw-r--r-- | src/views.rs | 18 |
1 files changed, 13 insertions, 5 deletions
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 | } |