diff options
Diffstat (limited to 'src/app/cursor.rs')
-rw-r--r-- | src/app/cursor.rs | 22 |
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 { | |||
16 | 0: Local::now().naive_local().date(), | 16 | 0: Local::now().naive_local().date(), |
17 | } | 17 | } |
18 | } | 18 | } |
19 | pub fn do_move(&mut self, d: Absolute) { | 19 | pub fn small_seek(&mut self, d: Absolute) { |
20 | let today = Local::now().naive_local().date(); | 20 | let today = Local::now().naive_local().date(); |
21 | let cursor = self.0; | 21 | let cursor = self.0; |
22 | match d { | 22 | match d { |
@@ -48,4 +48,24 @@ impl Cursor { | |||
48 | Absolute::None => {} | 48 | Absolute::None => {} |
49 | } | 49 | } |
50 | } | 50 | } |
51 | fn long_seek(&mut self, offset: Duration) { | ||
52 | let cursor = self.0; | ||
53 | let today = Local::now().naive_local().date(); | ||
54 | let next = cursor.checked_add_signed(offset).unwrap_or(cursor); | ||
55 | |||
56 | if next <= today { | ||
57 | self.0 = next; | ||
58 | } else { | ||
59 | self.0 = today; | ||
60 | } | ||
61 | } | ||
62 | pub fn month_forward(&mut self) { | ||
63 | self.long_seek(Duration::weeks(4)); | ||
64 | } | ||
65 | pub fn month_backward(&mut self) { | ||
66 | self.long_seek(Duration::weeks(-4)); | ||
67 | } | ||
68 | pub fn reset(&mut self) { | ||
69 | self.0 = Local::now().naive_local().date(); | ||
70 | } | ||
51 | } | 71 | } |