summaryrefslogtreecommitdiffstats
path: root/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-03-22 11:47:46 +0100
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-03-22 11:47:46 +0100
commit9f75546ee8fe2ad3ab07fee7bd9503340a5174fe (patch)
treea5f416bfcb0ee084164a8eb8703de628a9fc5946 /src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
parenttime-zone-fix (diff)
downloadUIC-barcode-9f75546ee8fe2ad3ab07fee7bd9503340a5174fe.tar
UIC-barcode-9f75546ee8fe2ad3ab07fee7bd9503340a5174fe.tar.gz
UIC-barcode-9f75546ee8fe2ad3ab07fee7bd9503340a5174fe.tar.bz2
UIC-barcode-9f75546ee8fe2ad3ab07fee7bd9503340a5174fe.tar.lz
UIC-barcode-9f75546ee8fe2ad3ab07fee7bd9503340a5174fe.tar.xz
UIC-barcode-9f75546ee8fe2ad3ab07fee7bd9503340a5174fe.tar.zst
UIC-barcode-9f75546ee8fe2ad3ab07fee7bd9503340a5174fe.zip
Diffstat (limited to 'src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java')
-rw-r--r--src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java72
1 files changed, 46 insertions, 26 deletions
diff --git a/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java b/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
index 0e7a044..7d82232 100644
--- a/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
+++ b/src/org/uic/barcode/ticket/api/asn/omv1/OpenTicketData.java
@@ -595,65 +595,85 @@ public class OpenTicketData extends Object {
if (this.validFromDay == null) {
this.validFromDay = 0L;
}
-
if (this.validUntilDay == null) {
return null;
}
-
-
return DateTimeUtils.getDate(issuingDate, this.validFromDay + this.validUntilDay, this.validUntilTime);
}
-
+
public void addActivatedDays(Collection<Long> days) {
-
if (days == null || days.isEmpty()) return;
-
if (this.activatedDay == null) {
this.activatedDay = new SequenceOfActivatedDays();
}
-
for (Long l : days) {
this.activatedDay.add(l);
}
-
}
+ /**
+ * Sets the activated days.
+ *
+ * @param dates the dates
+ * @param issuingDate the issuing date
+ * @param validFromDate the valid from date
+ */
+ public void setActivatedDays(Collection<Date> dates, Date issuingDate, Date validFromDate){
+ if (this.activatedDay != null) {
+ this.activatedDay.clear();
+ } else {
+ this.activatedDay= new SequenceOfActivatedDays();
+ }
+ long dateDif = 0L;
+ if (validFromDate != null) {
+ dateDif = DateTimeUtils.getDateDifference(issuingDate,validFromDate);
+ }
+ if (dates != null && !dates.isEmpty()) {
+ for (Date day : dates) {
+ this.addActivatedDay(issuingDate, dateDif, day);
+ }
+ }
+ }
+
- public void addActivatedDay(Date issuingDate, Date day){
-
- Long dayDiff = DateTimeUtils.getDateDifference(issuingDate, day);
-
+ /**
+ * Adds the activated day.
+ *
+ * @param issuingDate the issuing date in UTC
+ * @param dateOffset the date offset to be added to the issuing date
+ * @param day the day to be added
+ */
+ public void addActivatedDay(Date issuingDate, long dateOffset, Date day){
+ Long vDiff = DateTimeUtils.getDateDifferenceLocal(this.getValidFromDate(issuingDate), day);
if (this.activatedDay == null) {
this.activatedDay = new SequenceOfActivatedDays();
}
-
- if (dayDiff != null) {
- this.activatedDay.add(dayDiff);
+ if (vDiff != null) {
+ this.activatedDay.add(vDiff);
}
-
}
+ /**
+ * Gets the activated days.
+ *
+ * @param issuingDate the issuing date
+ * @return the activated days
+ */
public Collection<Date> getActivatedDays(Date issuingDate) {
-
if (this.activatedDay == null) return null;
-
ArrayList<Date> dates = new ArrayList<Date>();
-
for (Long diff: this.getActivatedDay()) {
-
- Date day = DateTimeUtils.getDate(issuingDate, diff, null);
-
+ Date day = DateTimeUtils.getDate(this.getValidFromDate(issuingDate), diff, null);
if (day != null) {
dates.add(day);
}
-
- }
-
+ }
return dates;
-
}
+
+
public Long getValidFromUTCOffset() {
return validFromUTCOffset;
}