diff options
author | Camil Staps | 2015-04-10 23:52:39 +0200 |
---|---|---|
committer | Camil Staps | 2015-04-10 23:52:39 +0200 |
commit | dc4bb981827dc16b9a55c896c82cfe0fed3dbf8e (patch) | |
tree | 5f28892edfce7ade29199f740a648db83589ff12 /app/src/main/java/com/camilstaps/common/Date.java | |
parent | More cleanup (diff) |
Swiping to previous dates works for daily readings (not for their bible texts)
Diffstat (limited to 'app/src/main/java/com/camilstaps/common/Date.java')
-rw-r--r-- | app/src/main/java/com/camilstaps/common/Date.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/src/main/java/com/camilstaps/common/Date.java b/app/src/main/java/com/camilstaps/common/Date.java index 94a306d..c01cc0d 100644 --- a/app/src/main/java/com/camilstaps/common/Date.java +++ b/app/src/main/java/com/camilstaps/common/Date.java @@ -66,6 +66,10 @@ public class Date implements Comparable<Date> { year += n; } + public void subtractYears(int n) { + year -= n; + } + public void addMonths(int n) { for (int i = 0; i < n; i++) { month++; @@ -76,6 +80,16 @@ public class Date implements Comparable<Date> { } } + public void subtractMonths(int n) { + for (int i = 0; i < n; i++) { + month--; + if (month <= 0) { + month = 12; + subtractYears(1); + } + } + } + public void addDays(int n) { for (int i = 0; i < n; i++) { day++; @@ -86,6 +100,16 @@ public class Date implements Comparable<Date> { } } + public void subtractDays(int n) { + for (int i = 0; i < n; i++) { + day--; + if (day <= 0) { + month--; + day = daysOfMonth(); + } + } + } + public boolean equals(Date date) { return year == date.year && month == date.month && day == date.day; } |