A
A
Alexander Pankov2018-01-06 13:41:41
JavaScript
Alexander Pankov, 2018-01-06 13:41:41

How to calculate the spent value as a percentage of the worker?

Hello.
I have
- start time
- end time
- current time It is

necessary to show on the screen how many percent of the beginning of the working day has already passed, you need to show the "fullness indicator"

I sketched an example where from 10 to 23 is a working day and the green bar shows what time it is now , but I see that it doesn’t work correctly, the green strip is not in its place, approximately there, of course, but it’s still not right, and for some reason the first hour of working time is swallowed up somewhere (it starts not from 10, but from 11 and I don't understand why)
link to codepen Thanks

in advance for help with the location of the green bar and the first hour

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Gerasimov, 2018-01-06
@Omashu

end / start * 100 = %
Just calculate the end mark, the start mark and get the percentage, everything is somehow confused with the pene code

S
Stalker_RED, 2018-01-06
@Stalker_RED

And the timestamps on the timeline (spans) do not fall because the last two labels do not have indents.
It's better to give them a fixed width, and center the text.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question