diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java index e4cbe0b..08d78a2 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java @@ -291,6 +291,10 @@ public class TimeCalcKeyAdapter extends KeyAdapter { } break; case Calendar.DAY_OF_MONTH: + System.out.println("oldMonth=" + oldMonth); + System.out.println("newMonth=" + newMonth); + System.out.println("oldDay=" + oldDay); + System.out.println("newDay=" + newDay); if (oldMonth != newMonth) { updateProperty(timeCalcConfiguration.testMonthCustomProperty, increase, decrease, reset, Calendar.MONTH); } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/WeekStatistics.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/WeekStatistics.java index 15da086..d205d3e 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/WeekStatistics.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/WeekStatistics.java @@ -4,6 +4,7 @@ import lombok.Getter; import org.nanoboot.utils.timecalc.swing.progress.AnalogClock; import org.nanoboot.utils.timecalc.swing.progress.Time; +import java.time.DateTimeException; import java.time.DayOfWeek; import java.time.LocalDate; import java.util.Calendar; @@ -24,15 +25,14 @@ public class WeekStatistics { int workDaysTodoTmp = 0; int workDaysTotalTmp; { - int currentDayOfMonth = analogClock.dayProperty.getValue(); + int currentDayOfMonth = time.dayProperty.getValue(); for (int dayOfMonth = 1; dayOfMonth <= time.asCalendar() .getActualMaximum(Calendar.DAY_OF_MONTH); dayOfMonth++) { - DayOfWeek dayOfWeek - = LocalDate.of(analogClock.yearProperty.getValue(), - analogClock.monthProperty.getValue(), + DayOfWeek dayOfWeek = LocalDate.of(time.yearProperty.getValue(), + time.monthProperty.getValue(), dayOfMonth) .getDayOfWeek(); boolean weekend diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Time.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Time.java index 4446d4e..d7aa2e3 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Time.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/progress/Time.java @@ -91,12 +91,13 @@ public class Time extends Thread { || month == 6 || month == 9 || month == 11)) { if (month == 2) { - if (custom > 28) { - custom = 28; - } else { - if (custom > 30) { - custom = 30; - } + boolean leapYear = this.yearProperty.getValue() % 4 == 0; + if (custom > (leapYear ? 29 : 28)) { + custom = (leapYear ? 29 : 28); + } + } else { + if (custom > 30) { + custom = 30; } } } diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java index c46a25d..6a0b329 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/windows/MainWindow.java @@ -56,6 +56,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.StandardCopyOption; +import java.time.DateTimeException; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -104,7 +105,7 @@ public class MainWindow extends TWindow { private final ActivityRepositoryApi activityRepository; private final IntegerProperty forgetOvertimeProperty = new IntegerProperty("forgetOvertimeProperty", 0); - + private WeekStatistics weekStatistics = null; { ChangeListener valueMustBeTime = @@ -956,8 +957,22 @@ public class MainWindow extends TWindow { progressCircle.setDonePercent(done); progressSwing.setDonePercent(done); dayBattery.setDonePercent(done); - - WeekStatistics weekStatistics = new WeekStatistics(clock, time); + try { + WeekStatistics weekStatisticsTmp = new WeekStatistics(clock, time); + weekStatistics = weekStatisticsTmp; + } catch (DateTimeException e) { + System.out.println("time.monthProperty=" + time.monthProperty); + System.out.println("time.dayProperty=" + time.dayProperty); + System.out.println("time.monthCustomProperty=" + time.monthCustomProperty); + System.out.println("time.dayCustomProperty=" + time.dayCustomProperty); + e.printStackTrace(); + try { + Thread.sleep(1000); + } catch (InterruptedException interruptedException) { + interruptedException.printStackTrace(); + } +// return false; + } final boolean nowIsWeekend = weekStatistics.isNowIsWeekend(); final int workDaysDone = weekStatistics.getWorkDaysDone(); final int workDaysTotal = weekStatistics.getWorkDaysTotal(); diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java index 48da251..d10ff94 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/DateFormats.java @@ -14,7 +14,7 @@ public class DateFormats { public final static DateTimeFormatter DATE_TIME_FORMATTER_HHmmssSSS = DateTimeFormatter.ofPattern("HH:mm:ss:SSS"); public static DateFormat DATE_TIME_FORMATTER_LONG - = new SimpleDateFormat("EEEE : yyyy-MM-dd", Locale.ENGLISH); + = new SimpleDateFormat("yyyy-MM-dd : EEEE", Locale.ENGLISH); public static DateFormat DATE_TIME_FORMATTER_YYYYMMDD = new SimpleDateFormat("yyyy-MM-dd"); diff --git a/modules/time-calc-app/src/main/resources/help/Readme.md b/modules/time-calc-app/src/main/resources/help/Readme.md index 7a18d25..89385c3 100644 --- a/modules/time-calc-app/src/main/resources/help/Readme.md +++ b/modules/time-calc-app/src/main/resources/help/Readme.md @@ -36,14 +36,14 @@ Time Calc is inspired by this document: [report.ods](https://code.nanoboot.org/n ### Start of application -When "Time Calc" is started", user is asked for: - - start time ... like 7:30 - - overtime ... like 0:45 ... overtime is optional and the default value is 0:00 +When "Time Calc" is started", user should fill the correct value for: +- start time ... like 7:30 +- overtime ... like 0:45 ... overtime is optional and the default value is 0:00 ### Restart of application You can restart the app, if you press the **"Restart"** button. - - Then you are asked again for start time and overtime. +- Then you are asked again for start time and overtime. ### End of application @@ -55,16 +55,6 @@ You can stop the app, if you press the **"Exit"** button or click on the exit wi If these files are present, something special happens. -### .tc/starttime.txt - -This file contains the default start time - used during the previous run of the app. -If file starttime.txt does not exist, then the default start time is 7:00. - -### .tc/overtime.txt - -This file contains the default overtime - used during the previous run of the app. -If file overtime.txt does not exist, then the default overtime is 0:00. - ### ./tc/timecalc.conf Configuration is stored here. @@ -85,29 +75,29 @@ Optional assignments of profiles to numbers is stored here. ### 3 Visibility modes - * STRONGLY_COLORED - many colors - * WEAKLY_COLORED - darkened colors - * GRAY - gray colors - * NONE - widgets are hidden +* STRONGLY_COLORED - many colors +* WEAKLY_COLORED - darkened colors +* GRAY - gray colors +* NONE - widgets are hidden ### Widgets #### Analog Clock - * hour hand - * minute hand (can be disabled in configuration) - * second hand (can be disabled in configuration) - * millisecond hand (can be disabled in configuration) - * shows current year, month, day of month and day of week, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED - * shows yellow highlighted remaining time until end of today working hours, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED - * hands can be long or shorter (can be set in configuration) +* hour hand +* minute hand (can be disabled in configuration) +* second hand (can be disabled in configuration) +* millisecond hand (can be disabled in configuration) +* shows current year, month, day of month and day of week, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED +* shows yellow highlighted remaining time until end of today working hours, if analog clock is hovered by mouse cursor and Visibility is STRONGLY_COLORED +* hands can be long or shorter (can be set in configuration) #### Progress Square - * Show graphically day progress +* Show graphically day progress #### Progress Circle - * Show graphically day progress +* Show graphically day progress #### Hour Battery @@ -209,12 +199,12 @@ Smileys can be colored or white-black (can be set in configuration) ### New features - * Custom arrival target - * Split to Maven modules - * Junit, Mockito, etc. - * Checkstyle - * Sonarlint - * Sonarqube +* Custom arrival target +* Split to Maven modules +* Junit, Mockito, etc. +* Checkstyle +* Sonarlint +* Sonarqube ### Fix these known bugs