openproject
openproject copied to clipboard
Add ability to log hours in HH:MM format
Hello. When I log time with Open Project there is always a problem to convert
in mind HH:MM
format to the hours in floating point format. I suggest to change the interface and allow users to use additional field Time in HH:MM
at the "Log time" popup.
At the database
it will be still stored as hours
in float number format
and for any kind of calculation used the same format as well.
What do you think about such improvement? Should I continue to implement that and have a change to be merged next? It's only the UI change, hours will be still in float values at the database.
Have a look at screenshots with prototype:
![Screenshot 2021-07-10 at 16 17 10](https://user-images.githubusercontent.com/1463086/125164873-1dbd6a80-e19d-11eb-8cd1-c016b7d22d0e.png)
![Screenshot 2021-07-10 at 16 39 46](https://user-images.githubusercontent.com/1463086/125164938-77be3000-e19d-11eb-9797-e696d0d45186.png)
Hi @shapkarin , thanks for expressing your interest in this topic. There is already a ticket for this with some discussion at https://community.openproject.org/work_packages/33231
So in general, we would favor the possibility to have HH::MM inputs into time fields. It would be nice to paste decimal values and have that converted? What do you think?
Hello, @oliverguenther. Can you please explain what you mean about:
It would be nice to paste decimal values and have that converted? What do you think?
@oliverguenther I think to use both values for the UI. When user change HH:MM input there is Hours updates and opposite – change Hours and HH:MM calculates automatically.
not sure completely about math, here is the playground https://codepen.io/shapkarin/pen/gOLYLBm?editors=0012
+1 !
@oliverguenther fixed math! added other commit.
Here is how it works https://codepen.io/shapkarin/pen/gOLYLBm?editors=0012 hope all is current, we don't need any mistakes in log hours.
Will try to deal with Angular (that I never used before) to add the UI
UPD: there is still some mistake...
console.log(hoursToTime(1.12)) // outputs "01:07"
console.log(timeToHours('01:06')) // wrong: outputs 1.1 not 1.11
Currently I create some check at https://codepen.io/shapkarin/pen/gOLYLBm?editors=0012
[...Array(60)].forEach((_, i) => {
const value = `01:${padNum(i)}`;
const hours = timeToHours(value);
const time = hoursToTime(hours);
console.log(`input: ${value}, hours: ${hours}, time: ${time}`);
});
and there is no any problem when you convert time to hours, but there is some issue when you convert hours that are not in sync with HH:MM values, like 1.03
and 1.04
is the same value at HH:MM 01:02
Here is some logs
"input: 01:00, hours: 1.00, time: 01:00"
"input: 01:01, hours: 1.02, time: 01:01"
"input: 01:02, hours: 1.03, time: 01:02"
"input: 01:03, hours: 1.05, time: 01:03"
"input: 01:04, hours: 1.07, time: 01:04"
"input: 01:05, hours: 1.08, time: 01:05"
"input: 01:06, hours: 1.10, time: 01:06"
"input: 01:07, hours: 1.12, time: 01:07"
"input: 01:08, hours: 1.13, time: 01:08"
"input: 01:09, hours: 1.15, time: 01:09"
"input: 01:10, hours: 1.17, time: 01:10"
"input: 01:11, hours: 1.18, time: 01:11"
"input: 01:12, hours: 1.20, time: 01:12"
"input: 01:13, hours: 1.22, time: 01:13"
"input: 01:14, hours: 1.23, time: 01:14"
"input: 01:15, hours: 1.25, time: 01:15"
"input: 01:16, hours: 1.27, time: 01:16"
"input: 01:17, hours: 1.28, time: 01:17"
"input: 01:18, hours: 1.30, time: 01:18"
To use hours values like 1.04
, 1.05
and other, I should add seconds to the HH:MM
– HH:MM:SS
Hi @shapkarin , there's also the DurationEditField that handles editing of work package values here that would need the same formatting. We could extract your functionality into a service and then use that in the respective components.
https://github.com/opf/openproject/blob/dev/frontend/src/app/shared/components/fields/edit/field-types/duration-edit-field.component.ts
@oliverguenther thanks, it's definitely should be a service. Will try to create it this weekend but not sure that I can create the UI.
@shapkarin hi, do you have any progress? I look forward to this function.
@tuxmartin hello, thanks to notice. I can add service at the next weekend... not early. Next someone should add the UI
@tuxmartin can you help with UI integration? I can deal with service, but not with the Angular components...
@shapkarin No. I'm sorry. I know only Java and Python.
any news?
Closing old PRs. Please reopen if work is still being conducted on this.
@shapkarin hello, any news? It will be great feature.