summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkshay <nerdy@peppe.rs>2020-07-21 11:24:42 +0530
committerAkshay <nerdy@peppe.rs>2020-07-21 11:24:42 +0530
commit76a6e78ccbea125ab5b8c06ff254260759d3140c (patch)
tree5b759ebbbdfa8031e6a1c9236e807b2e77c1ca54
parent2a3be003015bac9c6a13549029b9fb4595e88384 (diff)
switch to local time over utc time
-rw-r--r--src/app/impl_self.rs4
-rw-r--r--src/views.rs18
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 {
}
pub fn status(&self) -> StatusLine {
- let today = chrono::Local::now().naive_utc().date();
+ let today = chrono::Local::now().naive_local().date();
let remaining = self.habits.iter().map(|h| h.remaining(today)).sum::<u32>();
let total = self.habits.iter().map(|h| h.goal()).sum::<u32>();
let completed = total - remaining;
@@ -207,7 +207,7 @@ impl App {
.iter_mut()
.find(|x| x.name() == name && x.is_auto());
if let Some(h) = target_habit {
- h.modify(Local::now().naive_utc().date(), event);
+ h.modify(Local::now().naive_local().date(), event);
}
};
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
let strikethrough = Style::from(Effect::Strikethrough);
let goal_status =
- self.view_month_offset() == 0 && self.reached_goal(Local::now().naive_utc().date());
+ self.view_month_offset() == 0 && self.reached_goal(Local::now().naive_local().date());
printer.with_style(
Style::merge(&[
@@ -77,12 +77,20 @@ where
.collect::<Vec<_>>();
for (week, line_nr) in days.chunks(7).zip(2..) {
let weekly_goal = self.goal() * week.len() as u32;
- let is_this_week = week.contains(&Local::now().naive_utc().date());
+ let is_this_week = week.contains(&Local::now().naive_local().date());
let remaining = week.iter().map(|&i| self.remaining(i)).sum::<u32>();
let completions = weekly_goal - remaining;
let full = CONFIGURATION.view_width - 8;
- let bars_to_fill = if weekly_goal > 0 {(completions * full as u32) / weekly_goal} else {0};
- let percentage = if weekly_goal > 0 {(completions as f64 * 100.) / weekly_goal as f64} else {0.0};
+ let bars_to_fill = if weekly_goal > 0 {
+ (completions * full as u32) / weekly_goal
+ } else {
+ 0
+ };
+ let percentage = if weekly_goal > 0 {
+ (completions as f64 * 100.) / weekly_goal as f64
+ } else {
+ 0.0
+ };
printer.with_style(future_style, |p| {
p.print((4, line_nr), &"─".repeat(full));
});
@@ -141,7 +149,7 @@ where
}
fn on_event(&mut self, e: Event) -> EventResult {
- let now = Local::now().naive_utc().date();
+ let now = Local::now().naive_local().date();
if self.is_auto() {
return EventResult::Ignored;
}