This commit is contained in:
Robert Vokac 2024-03-23 08:20:03 +01:00
parent 805ddd162f
commit 46ae2a8d5b
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
6 changed files with 57 additions and 47 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -91,15 +91,16 @@ public class Time extends Thread {
|| month == 6 || month == 9
|| month == 11)) {
if (month == 2) {
if (custom > 28) {
custom = 28;
boolean leapYear = this.yearProperty.getValue() % 4 == 0;
if (custom > (leapYear ? 29 : 28)) {
custom = (leapYear ? 29 : 28);
}
} else {
if (custom > 30) {
custom = 30;
}
}
}
}
return custom == Integer.MAX_VALUE ? real : custom;
}

View File

@ -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();

View File

@ -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");

View File

@ -36,7 +36,7 @@ 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:
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
@ -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.