Suggestion: modify GanttProject to accept fractions of a day for task duration

If I have a number of tasks - say, from my Work Breakdown Structure that take a few hours, then Gantt Project will take the input fraction of a day (e.g. 0.5 day = 4 hours) as 1 day. this will throw off the schedule completely when I include other tasks also.
I understand it will take a lot of extra trouble to have a newly designed UI with hours as input fields, but can this be a solution?

Allow user to input fractions of a day as task duration - do not round them up. Internally, convert to minutes and use the Java 8 Duration and Instant class to add minutes to the Date.

* #### plusMinutes

public [Duration](https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html) plusMinutes(long minutesToAdd)

Returns a copy of this duration with the specified duration in minutes added.

This instance is immutable and unaffected by this method call.

Parameters:

`minutesToAdd`  - the minutes to add, positive or negative

Returns:

a  `Duration`  based on this duration with the specified minutes added, not null

Throws:

`ArithmeticException`  - if numeric overflow occurs

also see

https://docs.oracle.com/javase/tutorial/datetime/iso/instant.html

The Instant class provides a variety of methods for manipulating an Instant. There are plus and minus methods for adding or subtracting time. The following code adds 1 hour to the current time:

Instant oneHourLater = Instant.now().plusHours(1);

There are methods for comparing instants, such as isAfter and isBefore. The until method returns how much time exists between two Instant objects. The following line of code reports how many seconds have occurred since the beginning of the Java epoch.

long secondsFromEpoch = Instant.ofEpochSecond(0L).until(Instant.now(), ChronoUnit.SECONDS);

The Instant class does not work with human units of time, such as years, months, or days. If you want to perform calculations in those units, you can convert an Instant to another class, such as LocalDateTime or ZonedDateTime, by binding the Instant with a time zone. You can then access the value in the desired units. The following code converts an Instant to a LocalDateTime object using the ofInstant method and the default time zone, and then prints out the date and time in a more readable form:

Instant timestamp; … LocalDateTime ldt = LocalDateTime.ofInstant(timestamp, ZoneId.systemDefault()); System.out.printf("%s %d %d at %d:%d%n", ldt.getMonth(), ldt.getDayOfMonth(), ldt.getYear(), ldt.getHour(), ldt.getMinute());

This feature requires a huge effort in terms of code rewriting, reengineering and refactoring. As @DmitryBarashev said some time ago:

This feature requires major rewriting of nearly half of the code base. It can be done by a very high skilled engineer in roughly a few weeks, and when I say “very high skilled”, I really mean it.

See: https://github.com/bardsoftware/ganttproject/issues/225#issuecomment-398388186

This is just the date calculation part - internally adding a duration in minutes to a date. Java 8 comes with a lot of functionality that was not there earlier.
I doubt it will be that difficult - but I don’t know the code :slight_smile:

It could be that simple if the only task of GanttProject was to print date calculations to the output.
However, we also have to draw rectangles over the canvas, bind mouse movements to rectangle width changes, scroll smoothly make all things aligned and so on. There is a lot of code which relies on task duration being non-negative integer.

The case when we restrict ourselves to just fractions of abstract “day”, leaving their interpretation to the user, is admittedly easier than full-featured support with business hours and all other user interface which normally must be there when it comes to durations in hours. However, it is still way more difficult than just date manipulation.

Surely, task durations will always be positive?!

The Java 8 class Period will make it easier to define a workday period (say, 8 hours).

I suggest this problem be solved in baby steps.
Allow user to input decimal fractions of a day, internally convert to minutes, user sets workday period in settings - initially assume as 8 hours. Use the new Java 8 classes for Duration, Instant, Period etc to manipulate.
For drawing the chart, simply round off to nearest day. In other words, you do not need to touch the drawing portion at all. Just pass in an integer as parameter to the drawing methods.

The keyword is integer.

Do you want to take up this task?

@DmitryBarashev Who is the original author of the code - is he or she not around any more?

correction: should say instead, For drawing the chart, simply round off to nearest period (1 hour block or 8 hour block etc)

It depends on the particular piece of code. Big part is written by me, but there are major contributions from other authors as well. I don’t know where they are now but anyway I am sure they don’t want to touch this code anymore.

ok, I thought you were a project manager trying to find a programmer to code it.
Since you are the main author of the application and know it best since it is your baby, :baby_symbol:
how come you don’t want to fix it?

why not? :smile: