aboutsummaryrefslogtreecommitdiff
path: root/src/views.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-07-21 06:54:42 +0100
committerAkshay <[email protected]>2020-07-21 06:54:42 +0100
commit76a6e78ccbea125ab5b8c06ff254260759d3140c (patch)
tree5b759ebbbdfa8031e6a1c9236e807b2e77c1ca54 /src/views.rs
parent2a3be003015bac9c6a13549029b9fb4595e88384 (diff)
switch to local time over utc time
Diffstat (limited to 'src/views.rs')
-rw-r--r--src/views.rs18
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 }