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
187339583b
commit
c6f9d75c49
@ -33,6 +33,11 @@ public class Battery extends Widget {
|
|||||||
setPreferredSize(new Dimension(40, 100));
|
setPreferredSize(new Dimension(40, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Battery(int i, int y, int height) {
|
||||||
|
this();
|
||||||
|
setBounds(i, y, height);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
if (totalHeight == 0) {
|
if (totalHeight == 0) {
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package org.nanoboot.utils.timecalc.gui.progress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert
|
||||||
|
* @since 21.02.2024
|
||||||
|
*/
|
||||||
|
public class DayBattery extends Battery{
|
||||||
|
public DayBattery(int x, int i, int i1) {
|
||||||
|
super(x, i, i1);
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@ package org.nanoboot.utils.timecalc.gui.progress;
|
|||||||
import org.nanoboot.utils.timecalc.gui.common.Toaster;
|
import org.nanoboot.utils.timecalc.gui.common.Toaster;
|
||||||
import org.nanoboot.utils.timecalc.utils.Constants;
|
import org.nanoboot.utils.timecalc.utils.Constants;
|
||||||
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.TimeHM;
|
||||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@ -60,7 +60,7 @@ public class WalkingHumanProgressAsciiArt extends JTextPane {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
public void printPercentToAscii(double percent, int hourRemains, int minuteRemains, double done,
|
public void printPercentToAscii(double percent, int hourRemains, int minuteRemains, double done,
|
||||||
double totalSecondsRemainsDouble, TimeHoursMinutes endTime) {
|
double totalSecondsRemainsDouble, TimeHM endTime) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
String msg = createMessage(hourRemains, minuteRemains, done, totalSecondsRemainsDouble, endTime);
|
String msg = createMessage(hourRemains, minuteRemains, done, totalSecondsRemainsDouble, endTime);
|
||||||
int percentInt = (int) (percent * 100);
|
int percentInt = (int) (percent * 100);
|
||||||
@ -146,7 +146,7 @@ public class WalkingHumanProgressAsciiArt extends JTextPane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String createMessage(int hourRemains, int minuteRemains, double done,
|
private String createMessage(int hourRemains, int minuteRemains, double done,
|
||||||
double totalSecondsRemainsDouble, TimeHoursMinutes endTime) {
|
double totalSecondsRemainsDouble, TimeHM endTime) {
|
||||||
String msg = "Done=" + NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES.format(
|
String msg = "Done=" + NumberFormats.FORMATTER_FIVE_DECIMAL_PLACES.format(
|
||||||
done * 100) + "% Remains="
|
done * 100) + "% Remains="
|
||||||
+ String.format("%02d", hourRemains) + ":" + String
|
+ String.format("%02d", hourRemains) + ":" + String
|
||||||
|
@ -7,14 +7,14 @@ import org.nanoboot.utils.timecalc.gui.common.Toaster;
|
|||||||
import org.nanoboot.utils.timecalc.gui.common.WeatherWindow;
|
import org.nanoboot.utils.timecalc.gui.common.WeatherWindow;
|
||||||
import org.nanoboot.utils.timecalc.gui.progress.AnalogClock;
|
import org.nanoboot.utils.timecalc.gui.progress.AnalogClock;
|
||||||
import org.nanoboot.utils.timecalc.gui.progress.Battery;
|
import org.nanoboot.utils.timecalc.gui.progress.Battery;
|
||||||
|
import org.nanoboot.utils.timecalc.gui.progress.DayBattery;
|
||||||
import org.nanoboot.utils.timecalc.gui.progress.ProgressCircle;
|
import org.nanoboot.utils.timecalc.gui.progress.ProgressCircle;
|
||||||
import org.nanoboot.utils.timecalc.gui.progress.ProgressSquare;
|
import org.nanoboot.utils.timecalc.gui.progress.ProgressSquare;
|
||||||
import org.nanoboot.utils.timecalc.gui.progress.WalkingHumanProgressAsciiArt;
|
import org.nanoboot.utils.timecalc.gui.progress.WalkingHumanProgressAsciiArt;
|
||||||
import org.nanoboot.utils.timecalc.utils.Constants;
|
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.TimeHM;
|
||||||
import org.nanoboot.utils.timecalc.utils.TimeHoursMinutes;
|
|
||||||
import org.nanoboot.utils.timecalc.utils.Utils;
|
import org.nanoboot.utils.timecalc.utils.Utils;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
@ -28,8 +28,6 @@ import java.time.LocalDate;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static org.nanoboot.utils.timecalc.utils.FileConstants.FOCUS_TXT;
|
import static org.nanoboot.utils.timecalc.utils.FileConstants.FOCUS_TXT;
|
||||||
|
|
||||||
@ -43,9 +41,9 @@ public class TimeCalcManager {
|
|||||||
private final String windowTitle;
|
private final String windowTitle;
|
||||||
private final int totalMinutes;
|
private final int totalMinutes;
|
||||||
|
|
||||||
private final TimeHoursMinutes startTime;
|
private final TimeHM startTime;
|
||||||
private final TimeHoursMinutes overtime;
|
private final TimeHM overtime;
|
||||||
private final TimeHoursMinutes endTime;
|
private final TimeHM endTime;
|
||||||
private boolean stopBeforeEnd = false;
|
private boolean stopBeforeEnd = false;
|
||||||
private boolean vtipyShown = false;
|
private boolean vtipyShown = false;
|
||||||
|
|
||||||
@ -58,15 +56,15 @@ public class TimeCalcManager {
|
|||||||
overTimeIn = (overTimeIn == null || overTimeIn.isEmpty()) ?
|
overTimeIn = (overTimeIn == null || overTimeIn.isEmpty()) ?
|
||||||
Constants.DEFAULT_OVERTIME : overTimeIn;
|
Constants.DEFAULT_OVERTIME : overTimeIn;
|
||||||
|
|
||||||
this.startTime = new TimeHoursMinutes(startTimeIn);
|
this.startTime = new TimeHM(startTimeIn);
|
||||||
this.overtime = new TimeHoursMinutes(overTimeIn);
|
this.overtime = new TimeHM(overTimeIn);
|
||||||
|
|
||||||
this.endTime = new TimeHoursMinutes(startTime.getHour() + Constants.WORKING_HOURS_LENGTH + overtime.getHour(),
|
this.endTime = new TimeHM(startTime.getHour() + Constants.WORKING_HOURS_LENGTH + overtime.getHour(),
|
||||||
startTime.getMinute() + Constants.WORKING_MINUTES_LENGTH + overtime.getMinute());
|
startTime.getMinute() + Constants.WORKING_MINUTES_LENGTH + overtime.getMinute());
|
||||||
|
|
||||||
this.totalMinutes = TimeHoursMinutes.countDiffInMinutes(startTime, endTime);
|
this.totalMinutes = TimeHM.countDiffInMinutes(startTime, endTime);
|
||||||
int totalSeconds = totalMinutes * TimeHoursMinutes.SECONDS_PER_MINUTE;
|
int totalSeconds = totalMinutes * TimeHM.SECONDS_PER_MINUTE;
|
||||||
int totalMilliseconds = totalSeconds * TimeHoursMinutes.MILLISECONDS_PER_SECOND;
|
int totalMilliseconds = totalSeconds * TimeHM.MILLISECONDS_PER_SECOND;
|
||||||
|
|
||||||
TimeCalcWindow window = new TimeCalcWindow();
|
TimeCalcWindow window = new TimeCalcWindow();
|
||||||
|
|
||||||
@ -226,16 +224,14 @@ public class TimeCalcManager {
|
|||||||
.getWidth() + MARGIN, MARGIN, 80);
|
.getWidth() + MARGIN, MARGIN, 80);
|
||||||
window.add(progressCircle);
|
window.add(progressCircle);
|
||||||
|
|
||||||
Battery batteryForDay = new Battery();
|
Battery dayBattery = new DayBattery(progressCircle.getBounds().x,
|
||||||
batteryForDay.setBounds(progressCircle.getBounds().x,
|
|
||||||
progressCircle.getY() + MARGIN + progressCircle.getHeight(), 140);
|
progressCircle.getY() + MARGIN + progressCircle.getHeight(), 140);
|
||||||
window.add(batteryForDay);
|
window.add(dayBattery);
|
||||||
|
|
||||||
Battery batteryForWeek = new Battery();
|
Battery weekBattery = new Battery(
|
||||||
batteryForWeek.setBounds(
|
dayBattery.getBounds().x + dayBattery.getWidth(),
|
||||||
batteryForDay.getBounds().x + batteryForDay.getWidth(),
|
dayBattery.getY(), 140);
|
||||||
batteryForDay.getY(), 140);
|
window.add(weekBattery);
|
||||||
window.add(batteryForWeek);
|
|
||||||
|
|
||||||
Calendar calNow = Calendar.getInstance();
|
Calendar calNow = Calendar.getInstance();
|
||||||
calNow.setTime(new Date());
|
calNow.setTime(new Date());
|
||||||
@ -267,28 +263,22 @@ public class TimeCalcManager {
|
|||||||
|| currentDayOfWeekAsString.equals("SUNDAY");
|
|| currentDayOfWeekAsString.equals("SUNDAY");
|
||||||
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
workDaysTotal = workDaysDone + (nowIsWeekend ? 0 : 1) + workDaysTodo;
|
||||||
|
|
||||||
// System.out.println("workDaysDone" + workDaysDone);
|
Battery monthBattery = new Battery(
|
||||||
// System.out.println("workDaysTodo" + workDaysTodo);
|
dayBattery.getBounds().x + dayBattery.getWidth(),
|
||||||
// System.out.println("currentDayOfMonth" + currentDayOfMonth);
|
dayBattery.getY() + weekBattery.getHeight() + MARGIN, 140);
|
||||||
|
window.add(monthBattery);
|
||||||
|
|
||||||
Battery batteryForMonth = new Battery();
|
Battery hourBattery = new Battery(monthBattery.getBounds().x,
|
||||||
batteryForMonth.setBounds(
|
monthBattery.getY() + monthBattery.getHeight() + MARGIN, 140);
|
||||||
batteryForDay.getBounds().x + batteryForDay.getWidth(),
|
window.add(hourBattery);
|
||||||
batteryForDay.getY() + batteryForWeek.getHeight() + MARGIN, 140);
|
Rectangle hourRectangle = hourBattery.getBounds();
|
||||||
window.add(batteryForMonth);
|
Rectangle dayRectangle = dayBattery.getBounds();
|
||||||
|
Rectangle weekRectangle = weekBattery.getBounds();
|
||||||
Battery batteryForHour = new Battery();
|
Rectangle monthRectangle = monthBattery.getBounds();
|
||||||
batteryForHour.setBounds(batteryForMonth.getBounds().x,
|
hourBattery.setBounds(dayRectangle);
|
||||||
batteryForMonth.getY() + batteryForMonth.getHeight() + MARGIN, 140);
|
dayBattery.setBounds(weekRectangle);
|
||||||
window.add(batteryForHour);
|
weekBattery.setBounds(monthRectangle);
|
||||||
Rectangle hourRectangle = batteryForHour.getBounds();
|
monthBattery.setBounds(hourRectangle);
|
||||||
Rectangle dayRectangle = batteryForDay.getBounds();
|
|
||||||
Rectangle weekRectangle = batteryForWeek.getBounds();
|
|
||||||
Rectangle monthRectangle = batteryForMonth.getBounds();
|
|
||||||
batteryForHour.setBounds(dayRectangle);
|
|
||||||
batteryForDay.setBounds(weekRectangle);
|
|
||||||
batteryForWeek.setBounds(monthRectangle);
|
|
||||||
batteryForMonth.setBounds(hourRectangle);
|
|
||||||
|
|
||||||
ComponentRegistry componentRegistry = new ComponentRegistry();
|
ComponentRegistry componentRegistry = new ComponentRegistry();
|
||||||
componentRegistry.addAll(
|
componentRegistry.addAll(
|
||||||
@ -296,10 +286,10 @@ public class TimeCalcManager {
|
|||||||
progressSquare,
|
progressSquare,
|
||||||
progressCircle,
|
progressCircle,
|
||||||
analogClock,
|
analogClock,
|
||||||
batteryForDay,
|
dayBattery,
|
||||||
batteryForWeek,
|
weekBattery,
|
||||||
batteryForMonth,
|
monthBattery,
|
||||||
batteryForHour,
|
hourBattery,
|
||||||
jokeButton,
|
jokeButton,
|
||||||
focusButton,
|
focusButton,
|
||||||
commandButton,
|
commandButton,
|
||||||
@ -324,7 +314,6 @@ public class TimeCalcManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentRegistry.setVisible(!Utils.everythingHidden.get());
|
componentRegistry.setVisible(!Utils.everythingHidden.get());
|
||||||
|
|
||||||
jokeButton.setVisible(
|
jokeButton.setVisible(
|
||||||
TimeCalcConf.getInstance().isJokeVisible()
|
TimeCalcConf.getInstance().isJokeVisible()
|
||||||
&& !Utils.everythingHidden.get());
|
&& !Utils.everythingHidden.get());
|
||||||
@ -349,17 +338,13 @@ public class TimeCalcManager {
|
|||||||
int minuteNow = Integer.parseInt(nowString.split(":")[1]);
|
int minuteNow = Integer.parseInt(nowString.split(":")[1]);
|
||||||
int secondNow = Integer.parseInt(nowString.split(":")[2]);
|
int secondNow = Integer.parseInt(nowString.split(":")[2]);
|
||||||
int millisecondNow = Integer.parseInt(nowString.split(":")[3]);
|
int millisecondNow = Integer.parseInt(nowString.split(":")[3]);
|
||||||
int hourRemains = endTime.getHour() - hourNow;
|
TimeHM timeRemains = new TimeHM(endTime.getHour() - hourNow, endTime.getMinute() - minuteNow);
|
||||||
int minuteRemains = endTime.getMinute() - minuteNow;
|
|
||||||
if (minuteRemains < 0) {
|
|
||||||
minuteRemains = minuteRemains + 60;
|
|
||||||
hourRemains = hourRemains - 1;
|
|
||||||
}
|
|
||||||
int secondsRemains = 60 - secondNow;
|
int secondsRemains = 60 - secondNow;
|
||||||
int millisecondsRemains = 1000 - millisecondNow;
|
int millisecondsRemains = 1000 - millisecondNow;
|
||||||
|
|
||||||
int hourDone = Constants.WORKING_HOURS_LENGTH + overtime.getHour() - hourRemains;
|
int hourDone = Constants.WORKING_HOURS_LENGTH + overtime.getHour() - timeRemains.getHour();
|
||||||
int minutesDone = Constants.WORKING_MINUTES_LENGTH + overtime.getMinute() - minuteRemains;
|
int minutesDone = Constants.WORKING_MINUTES_LENGTH + overtime.getMinute() - timeRemains.getMinute();
|
||||||
int secondsDone = secondNow;
|
int secondsDone = secondNow;
|
||||||
int millisecondsDone = millisecondNow;
|
int millisecondsDone = millisecondNow;
|
||||||
|
|
||||||
@ -372,24 +357,24 @@ public class TimeCalcManager {
|
|||||||
/ ((double) totalMilliseconds);
|
/ ((double) totalMilliseconds);
|
||||||
progressSquare.setDonePercent(done);
|
progressSquare.setDonePercent(done);
|
||||||
progressCircle.setDonePercent(done);
|
progressCircle.setDonePercent(done);
|
||||||
batteryForDay.setDonePercent(done);
|
dayBattery.setDonePercent(done);
|
||||||
|
|
||||||
int weekDayWhenMondayIsOne = calNow.get(Calendar.DAY_OF_WEEK) - 1;
|
int weekDayWhenMondayIsOne = calNow.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
batteryForWeek.setDonePercent((weekDayWhenMondayIsOne == 0
|
weekBattery.setDonePercent((weekDayWhenMondayIsOne == 0
|
||||||
|| weekDayWhenMondayIsOne == 6) ?
|
|| weekDayWhenMondayIsOne == 6) ?
|
||||||
100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20));
|
100 : ((weekDayWhenMondayIsOne - 1) * 0.20 + done * 0.20));
|
||||||
batteryForWeek.setLabel(
|
weekBattery.setLabel(
|
||||||
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
nowIsWeekend ? "5/5" : (weekDayWhenMondayIsOne + "/5"));
|
||||||
|
|
||||||
batteryForMonth.setDonePercent(weekDayWhenMondayIsOne == 0
|
monthBattery.setDonePercent(weekDayWhenMondayIsOne == 0
|
||||||
|| weekDayWhenMondayIsOne == 6 ?
|
|| weekDayWhenMondayIsOne == 6 ?
|
||||||
workDaysDone / workDaysTotal :
|
workDaysDone / workDaysTotal :
|
||||||
(workDaysDone + done) / workDaysTotal);
|
(workDaysDone + done) / workDaysTotal);
|
||||||
batteryForMonth.setLabel(
|
monthBattery.setLabel(
|
||||||
(nowIsWeekend ? workDaysDone : workDaysDone + 1) + "/"
|
(nowIsWeekend ? workDaysDone : workDaysDone + 1) + "/"
|
||||||
+ (workDaysTotal));
|
+ (workDaysTotal));
|
||||||
|
|
||||||
double minutesRemainsD = minuteRemains;
|
double minutesRemainsD = timeRemains.getMinute();
|
||||||
double secondsRemainsD = secondsRemains;
|
double secondsRemainsD = secondsRemains;
|
||||||
double millisecondsRemainsD = millisecondsRemains;
|
double millisecondsRemainsD = millisecondsRemains;
|
||||||
minutesRemainsD = minutesRemainsD + secondsRemainsD / 60d;
|
minutesRemainsD = minutesRemainsD + secondsRemainsD / 60d;
|
||||||
@ -401,19 +386,19 @@ public class TimeCalcManager {
|
|||||||
if (millisecondsRemainsD > 0) {
|
if (millisecondsRemainsD > 0) {
|
||||||
minutesRemainsD = minutesRemainsD - 1d / 1000d;
|
minutesRemainsD = minutesRemainsD - 1d / 1000d;
|
||||||
}
|
}
|
||||||
batteryForHour.setDonePercent(
|
hourBattery.setDonePercent(
|
||||||
done >= 1 ? 1 : (1 - ((minutesRemainsD % 60d) / 60d)));
|
done >= 1 ? 1 : (1 - ((minutesRemainsD % 60d) / 60d)));
|
||||||
if (!nowIsWeekend) {
|
if (!nowIsWeekend) {
|
||||||
int hoursForLabel =
|
int hoursForLabel =
|
||||||
(minuteRemains == 0 ? minuteRemains / 60 + 1 :
|
(timeRemains.getMinute() == 0 ? timeRemains.getMinute() / 60 + 1 :
|
||||||
minuteRemains / 60);
|
timeRemains.getMinute() / 60);
|
||||||
batteryForHour.setLabel(
|
hourBattery.setLabel(
|
||||||
((totalMinutes / 60) - hoursForLabel) + "/" + (
|
((totalMinutes / 60) - hoursForLabel) + "/" + (
|
||||||
totalMinutes / 60));
|
totalMinutes / 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalSecondsRemains =
|
int totalSecondsRemains =
|
||||||
(hourRemains * 60 * 60 + minuteRemains * 60
|
(timeRemains.getHour() * 60 * 60 + timeRemains.getMinute() * 60
|
||||||
+ secondsRemains);
|
+ secondsRemains);
|
||||||
int totalMillisecondsRemains =
|
int totalMillisecondsRemains =
|
||||||
totalSecondsRemains * 1000 + millisecondsRemains;
|
totalSecondsRemains * 1000 + millisecondsRemains;
|
||||||
@ -428,21 +413,21 @@ public class TimeCalcManager {
|
|||||||
// } else {
|
// } else {
|
||||||
// sb.append(msg);
|
// sb.append(msg);
|
||||||
// }
|
// }
|
||||||
if (hourRemains == 0 && minuteRemains == 1 && !vtipyShown) {
|
if (timeRemains.getHour() == 0 && timeRemains.getMinute() == 1 && !vtipyShown) {
|
||||||
vtipyShown = true;
|
vtipyShown = true;
|
||||||
Jokes.showRandom();
|
Jokes.showRandom();
|
||||||
}
|
}
|
||||||
if (hourRemains == 0 && minuteRemains <= 3) {
|
if (timeRemains.getHour() == 0 && timeRemains.getMinute() <= 3) {
|
||||||
Utils.highlighted.set(true);
|
Utils.highlighted.set(true);
|
||||||
walkingHumanProgressAsciiArt.setForeground(Color.BLUE);
|
walkingHumanProgressAsciiArt.setForeground(Color.BLUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hourRemains <= 0 && minuteRemains <= 0) {
|
if (timeRemains.getHour() <= 0 && timeRemains.getMinute() <= 0) {
|
||||||
Toaster toasterManager = new Toaster();
|
Toaster toasterManager = new Toaster();
|
||||||
toasterManager.setDisplayTime(30000);
|
toasterManager.setDisplayTime(30000);
|
||||||
toasterManager.showToaster(
|
toasterManager.showToaster(
|
||||||
"Congratulation :-) It is the time to go home.");
|
"Congratulation :-) It is the time to go home.");
|
||||||
walkingHumanProgressAsciiArt.printPercentToAscii(done, hourRemains, minuteRemains, done,totalSecondsRemainsDouble, endTime);
|
walkingHumanProgressAsciiArt.printPercentToAscii(done, timeRemains.getHour(), timeRemains.getMinute(), done,totalSecondsRemainsDouble, endTime);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10000);
|
Thread.sleep(10000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -456,7 +441,7 @@ public class TimeCalcManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
walkingHumanProgressAsciiArt.printPercentToAscii(done, hourRemains, minuteRemains, done,totalSecondsRemainsDouble, endTime);
|
walkingHumanProgressAsciiArt.printPercentToAscii(done, timeRemains.getHour(), timeRemains.getMinute(), done,totalSecondsRemainsDouble, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -4,10 +4,10 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert
|
* @author pc00289
|
||||||
* @since 21.02.2024
|
* @since 21.02.2024
|
||||||
*/
|
*/
|
||||||
public class TimeHoursMinutes {
|
public class TimeHM {
|
||||||
public static final int MINUTES_PER_HOUR = 60;
|
public static final int MINUTES_PER_HOUR = 60;
|
||||||
public static final int MILLISECONDS_PER_SECOND = 1000;
|
public static final int MILLISECONDS_PER_SECOND = 1000;
|
||||||
public static final int SECONDS_PER_MINUTE = 60;
|
public static final int SECONDS_PER_MINUTE = 60;
|
||||||
@ -17,7 +17,7 @@ public class TimeHoursMinutes {
|
|||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private Integer minute;
|
private Integer minute;
|
||||||
|
|
||||||
public TimeHoursMinutes(String string) {
|
public TimeHM(String string) {
|
||||||
boolean isNegative = string.startsWith("-");
|
boolean isNegative = string.startsWith("-");
|
||||||
if (isNegative) {
|
if (isNegative) {
|
||||||
string = string.replace("-", "");
|
string = string.replace("-", "");
|
||||||
@ -27,16 +27,20 @@ public class TimeHoursMinutes {
|
|||||||
this.minute = (isNegative ? (-1) : 1) * Integer.valueOf(array[1]);
|
this.minute = (isNegative ? (-1) : 1) * Integer.valueOf(array[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeHoursMinutes(int hourIn, int minuteIn) {
|
public TimeHM(int hourIn, int minuteIn) {
|
||||||
this.hour = hourIn;
|
this.hour = hourIn;
|
||||||
this.minute = minuteIn;
|
this.minute = minuteIn;
|
||||||
while (minute >= MINUTES_PER_HOUR) {
|
while (minute >= MINUTES_PER_HOUR) {
|
||||||
minute = minute - MINUTES_PER_HOUR;
|
minute = minute - MINUTES_PER_HOUR;
|
||||||
hour = hour + 1;
|
hour = hour + 1;
|
||||||
}
|
}
|
||||||
|
if (minute < 0) {
|
||||||
|
minute = minute + 60;
|
||||||
|
hour = hour - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int countDiffInMinutes(TimeHoursMinutes startTime, TimeHoursMinutes endTime) {
|
public static int countDiffInMinutes(TimeHM startTime, TimeHM endTime) {
|
||||||
return (endTime.getHour() * TimeHoursMinutes.MINUTES_PER_HOUR + endTime.getMinute()) - (startTime.getHour() * TimeHoursMinutes.MINUTES_PER_HOUR + startTime.getMinute());
|
return (endTime.getHour() * TimeHM.MINUTES_PER_HOUR + endTime.getMinute()) - (startTime.getHour() * TimeHM.MINUTES_PER_HOUR + startTime.getMinute());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user