summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org
diff options
context:
space:
mode:
authorJonathan Bauer2016-08-17 17:27:29 +0200
committerJonathan Bauer2016-08-17 17:27:29 +0200
commit6ee04efd70debc5efd59cc8842ced3511dcd4d49 (patch)
tree4b726a1e8ae16e7a6cc8ea0ff77c469b22e233e7 /dozentenmodul/src/main/java/org
parent[client] Check for vmware lock file when user selects a vm for upload (diff)
downloadtutor-module-6ee04efd70debc5efd59cc8842ced3511dcd4d49.tar.gz
tutor-module-6ee04efd70debc5efd59cc8842ced3511dcd4d49.tar.xz
tutor-module-6ee04efd70debc5efd59cc8842ced3511dcd4d49.zip
[client] reworked buggy days left calculations
Diffstat (limited to 'dozentenmodul/src/main/java/org')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/util/FormatHelper.java38
1 files changed, 14 insertions, 24 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/FormatHelper.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/FormatHelper.java
index 2580e209..6f129931 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/FormatHelper.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/FormatHelper.java
@@ -1,14 +1,7 @@
package org.openslx.dozmod.util;
-import java.util.Calendar;
-
-import org.joda.time.DateTime;
-import org.joda.time.Days;
-import org.joda.time.Period;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
-import org.joda.time.format.PeriodFormat;
-import org.joda.time.format.PeriodFormatter;
import org.openslx.bwlp.thrift.iface.Location;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.bwlp.thrift.iface.Organization;
@@ -130,26 +123,23 @@ public class FormatHelper {
* the same as longDate
*/
public static String daysTil(final long timestamp) {
- Period period = new Period(DateTime.now().getMillis(), timestamp * 1000);
- if (period.getYears() > 0 || period.getMonths() > 0 || period.getWeeks() > 2) {
+ long minutesLeft = (timestamp * 1000 - System.currentTimeMillis()) / ( 1000 * 60 );
+ long hoursLeft = minutesLeft / 60;
+ long daysLeft = hoursLeft / 24;
+ if (minutesLeft <= 0)
+ return "-";
+ if (daysLeft > 14) {
return longDate(timestamp);
+ } else if (daysLeft >= 1) {
+ return new String(daysLeft + " Tag(e)");
+ } else if (hoursLeft > 0) {
+ return new String(hoursLeft + " Stunde(n)");
+ } else if (minutesLeft > 0){
+ return new String(minutesLeft + " Minute(n)");
} else {
- // under 2 weeks, get the days and add the week if any
- int daysLeft = period.getDays();
- if (period.getWeeks() == 1)
- daysLeft += 7;
- if (daysLeft <= 14 && daysLeft >= 1) {
- return new String(daysLeft + " Tag(e)");
- } else if (daysLeft == 0) {
- int hoursLeft = period.getHours();
- if (hoursLeft != 0) {
- return new String(hoursLeft + " Stunde(n)");
- } else {
- return new String(period.getMinutes() + " Minute(n)");
- }
- }
+ return "-";
}
- return "-"; // Error
+
}
/**