summaryrefslogtreecommitdiffstats
path: root/src/app/cursor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/cursor.rs')
-rw-r--r--src/app/cursor.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/app/cursor.rs b/src/app/cursor.rs
index ed6bd65..f76d591 100644
--- a/src/app/cursor.rs
+++ b/src/app/cursor.rs
@@ -16,7 +16,7 @@ impl Cursor {
0: Local::now().naive_local().date(),
}
}
- pub fn do_move(&mut self, d: Absolute) {
+ pub fn small_seek(&mut self, d: Absolute) {
let today = Local::now().naive_local().date();
let cursor = self.0;
match d {
@@ -48,4 +48,24 @@ impl Cursor {
Absolute::None => {}
}
}
+ fn long_seek(&mut self, offset: Duration) {
+ let cursor = self.0;
+ let today = Local::now().naive_local().date();
+ let next = cursor.checked_add_signed(offset).unwrap_or(cursor);
+
+ if next <= today {
+ self.0 = next;
+ } else {
+ self.0 = today;
+ }
+ }
+ pub fn month_forward(&mut self) {
+ self.long_seek(Duration::weeks(4));
+ }
+ pub fn month_backward(&mut self) {
+ self.long_seek(Duration::weeks(-4));
+ }
+ pub fn reset(&mut self) {
+ self.0 = Local::now().naive_local().date();
+ }
}