mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
Added new improvements
This commit is contained in:
parent
ff211e391e
commit
83f4e130a2
2
pom.xml
2
pom.xml
@ -102,7 +102,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.22</version>
|
<version>1.18.20</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -11,6 +11,7 @@ import org.nanoboot.utils.timecalc.utils.Constants;
|
|||||||
import org.nanoboot.utils.timecalc.utils.DateFormats;
|
import org.nanoboot.utils.timecalc.utils.DateFormats;
|
||||||
import org.nanoboot.utils.timecalc.utils.Jokes;
|
import org.nanoboot.utils.timecalc.utils.Jokes;
|
||||||
import org.nanoboot.utils.timecalc.utils.NumberFormats;
|
import org.nanoboot.utils.timecalc.utils.NumberFormats;
|
||||||
|
import org.nanoboot.utils.timecalc.utils.TimeHoursMinutes;
|
||||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@ -47,12 +48,10 @@ public class TimeCalcWindow {
|
|||||||
private static final int MARGIN = 10;
|
private static final int MARGIN = 10;
|
||||||
|
|
||||||
private final String windowTitle;
|
private final String windowTitle;
|
||||||
private final int startHour;
|
|
||||||
private final int startMinute;
|
|
||||||
private final int overtimeHour;
|
|
||||||
private final int overtimeMinute;
|
|
||||||
private final int totalMinutes;
|
private final int totalMinutes;
|
||||||
private final Set<Integer> alreadyShownPercents = new HashSet<>();
|
private final Set<Integer> alreadyShownPercents = new HashSet<>();
|
||||||
|
private final TimeHoursMinutes startTime;
|
||||||
|
private final TimeHoursMinutes overtime;
|
||||||
private int endHour;
|
private int endHour;
|
||||||
private int endMinute;
|
private int endMinute;
|
||||||
private boolean stopBeforeEnd = false;
|
private boolean stopBeforeEnd = false;
|
||||||
@ -67,27 +66,17 @@ public class TimeCalcWindow {
|
|||||||
overTimeIn = (overTimeIn == null || overTimeIn.isEmpty()) ?
|
overTimeIn = (overTimeIn == null || overTimeIn.isEmpty()) ?
|
||||||
Constants.DEFAULT_OVERTIME : overTimeIn;
|
Constants.DEFAULT_OVERTIME : overTimeIn;
|
||||||
|
|
||||||
String[] startTimeAsArray = startTimeIn.split(":");
|
this.startTime = new TimeHoursMinutes(startTimeIn);
|
||||||
this.startHour = Integer.valueOf(startTimeAsArray[0]);
|
this.overtime = new TimeHoursMinutes(overTimeIn);
|
||||||
this.startMinute = Integer.valueOf(startTimeAsArray[1]);
|
|
||||||
|
|
||||||
boolean overtimeIsNegative = overTimeIn.startsWith("-");
|
this.endHour = startTime.getHour() + Constants.WORKING_HOURS_LENGTH + overtime.getHour();
|
||||||
if (overtimeIsNegative) {
|
this.endMinute = startTime.getMinute() + Constants.WORKING_MINUTES_LENGTH + overtime.getMinute();
|
||||||
overTimeIn = overTimeIn.replace("-", "");
|
|
||||||
}
|
|
||||||
this.overtimeHour = (overtimeIsNegative ? (-1) : 1) * Integer
|
|
||||||
.valueOf(overTimeIn.split(":")[0]);
|
|
||||||
this.overtimeMinute = (overtimeIsNegative ? (-1) : 1) * Integer
|
|
||||||
.valueOf(overTimeIn.split(":")[1]);
|
|
||||||
|
|
||||||
this.endHour = startHour + Constants.WORKING_HOURS_LENGTH + overtimeHour;
|
|
||||||
this.endMinute = startMinute + Constants.WORKING_MINUTES_LENGTH + overtimeMinute;
|
|
||||||
while (endMinute >= 60) {
|
while (endMinute >= 60) {
|
||||||
endMinute = endMinute - 60;
|
endMinute = endMinute - 60;
|
||||||
endHour = endHour + 1;
|
endHour = endHour + 1;
|
||||||
}
|
}
|
||||||
this.totalMinutes =
|
this.totalMinutes =
|
||||||
(endHour * 60 + endMinute) - (startHour * 60 + startMinute);
|
(endHour * 60 + endMinute) - (startTime.getHour() * 60 + startTime.getMinute());
|
||||||
int totalSeconds = totalMinutes * 60;
|
int totalSeconds = totalMinutes * 60;
|
||||||
int totalMilliseconds = totalSeconds * 1000;
|
int totalMilliseconds = totalSeconds * 1000;
|
||||||
|
|
||||||
@ -441,8 +430,8 @@ public class TimeCalcWindow {
|
|||||||
int secondsRemains = 60 - secondNow;
|
int secondsRemains = 60 - secondNow;
|
||||||
int millisecondsRemains = 1000 - millisecondNow;
|
int millisecondsRemains = 1000 - millisecondNow;
|
||||||
|
|
||||||
int hourDone = Constants.WORKING_HOURS_LENGTH + overtimeHour - hourRemains;
|
int hourDone = Constants.WORKING_HOURS_LENGTH + overtime.getHour() - hourRemains;
|
||||||
int minutesDone = Constants.WORKING_MINUTES_LENGTH + overtimeMinute - minuteRemains;
|
int minutesDone = Constants.WORKING_MINUTES_LENGTH + overtime.getMinute() - minuteRemains;
|
||||||
int secondsDone = secondNow;
|
int secondsDone = secondNow;
|
||||||
int millisecondsDone = millisecondNow;
|
int millisecondsDone = millisecondNow;
|
||||||
|
|
||||||
|
@ -1,17 +1,25 @@
|
|||||||
package org.nanoboot.utils.timecalc.utils;
|
package org.nanoboot.utils.timecalc.utils;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert
|
* @author Robert
|
||||||
* @since 21.02.2024
|
* @since 21.02.2024
|
||||||
*/
|
*/
|
||||||
public class TimeHoursMinutes {
|
public class TimeHoursMinutes {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final Integer hour;
|
private final Integer hour;
|
||||||
|
@Getter
|
||||||
private final Integer minute;
|
private final Integer minute;
|
||||||
|
|
||||||
public TimeHoursMinutes(String string) {
|
public TimeHoursMinutes(String string) {
|
||||||
|
boolean isNegative = string.startsWith("-");
|
||||||
|
if (isNegative) {
|
||||||
|
string = string.replace("-", "");
|
||||||
|
}
|
||||||
String[] array = string.split(":");
|
String[] array = string.split(":");
|
||||||
this.hour = Integer.valueOf(array[0]);
|
this.hour = (isNegative ? (-1) : 1) * Integer.valueOf(array[0]);
|
||||||
this.minute = Integer.valueOf(array[1]);
|
this.minute = (isNegative ? (-1) : 1) * Integer.valueOf(array[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user