aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/com/camilstaps/common/Date.java
diff options
context:
space:
mode:
authorCamil Staps2015-04-10 23:52:39 +0200
committerCamil Staps2015-04-10 23:52:39 +0200
commitdc4bb981827dc16b9a55c896c82cfe0fed3dbf8e (patch)
tree5f28892edfce7ade29199f740a648db83589ff12 /app/src/main/java/com/camilstaps/common/Date.java
parentMore 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.java24
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;
}