diff --git a/src/timesheet.rs b/src/timesheet.rs index 753707e..f53df77 100644 --- a/src/timesheet.rs +++ b/src/timesheet.rs @@ -77,6 +77,16 @@ impl TimeSheet { self.times.iter().map(TimePoint::to_string).collect() } + /** + * Adjust the current time by `minutes` and round the result to a multiple of `minutes`. + * This is so I can adjust in steps of 5 but still get nice, even numbers in the output. + */ + pub fn shift_current(&mut self, minutes: i64) { + let time = &mut self.times[self.selected].time; + let current_minute = time.minute() as i64; + *time += Duration::minutes(minutes - current_minute % minutes); + } + fn current(&self) -> &TimePoint { &self.times[self.selected] } diff --git a/src/tracc.rs b/src/tracc.rs index 8691217..d7b88d2 100644 --- a/src/tracc.rs +++ b/src/tracc.rs @@ -69,6 +69,8 @@ impl Tracc { } Key::Char('a') | Key::Char('A') => self.set_mode(Mode::Insert)?, Key::Char(' ') if self.focus == Focus::Top => self.todos.toggle_current(), + Key::Char('-') if self.focus == Focus::Bottom => self.times.shift_current(-5), + Key::Char('+') if self.focus == Focus::Bottom => self.times.shift_current(5), // dd Key::Char('d') => { if let Some(Ok(Key::Char('d'))) = inputs.next() {