+ 1

How do i solve this mathmarical error i noticed while using my own code for real world application

The output eror is more of how i do the math to solve the problem i noticed when putting 6:45 as the clock in time then putting 21:00 as the clockout time it give 15 Hours and 45 Minutes which is incorrect it show be 14 Hours and 15 Minutes so now to the question how do i fix this mathmatical error and how should i set up the Formula here is what i designed it around "((Hour out - Hour in) + (Minute out - Minute in)) = time worked" and i know its not really a mathmatical error because the webpage is saying thats what it got from the INSTRUCTION i gave it so its correct in the result of steps given it which means as i said above im solving the problem the wrong way to solve calculate shift hours https://code.sololearn.com/Wijn5IeidQEV/?ref=app

2nd Mar 2019, 10:21 PM
Brennan Woodroof
Brennan Woodroof - avatar
10 Antworten
+ 1
Holy lord, the SoloLearn app is mocking. I already posted my answer two times, but it disappeared due to a connection error. So here we go again. I wrote a quick & dirty solution. Take a look at it and try to apply it to your code. When I find some more time I'll fix your code, but right now that's what I got. In HTML5 there is a new input type: time. I put it into my code, but right now it doesn't do anything. https://code.sololearn.com/Wq8F92vVVFce/?ref=app
3rd Mar 2019, 1:17 AM
Pete Wright
Pete Wright - avatar
+ 1
Pete Wright Thanks the Variable names do have meanings as well example "hr1monin" stands for "hr" means an hour "1" stands for the top first hour intput(top) and the "mon" is for monday "in" stand for the clock in and if it has a "dis" in the variable it stands for display meaning that varible should be the one thats displayed in the browser
3rd Mar 2019, 12:32 AM
Brennan Woodroof
Brennan Woodroof - avatar
+ 1
Pete Wright i plan on rewritting the code anway as i learned about inputs a little more and the usage of labels and plan to use that to eliminate a table cell as well as seeing what your code does different than mine and teying to get the same effect as your code but use your as an example
3rd Mar 2019, 1:28 AM
Brennan Woodroof
Brennan Woodroof - avatar
+ 1
I just updated the code so now you can also use the <input type="time">
3rd Mar 2019, 1:52 AM
Pete Wright
Pete Wright - avatar
+ 1
Pete Wright how new is this input time type as i write my code on a 8 year old computer that may not support it i like solo learn but its easier and faster to code on a computer
3rd Mar 2019, 1:58 AM
Brennan Woodroof
Brennan Woodroof - avatar
+ 1
It only depends on the browser you use. Take a look at the browser support table: https://www.w3schools.com/tags/att_input_type_time.asp I also often use my computer that is nearly 8 years old, self-built from scratch with components reaching age as of 2009 and older. I use the latest Version of Opera for daily work and the latest version of Firefox as fallback. Everything from SoloLearn and w3schools.com perfectly works.
3rd Mar 2019, 2:03 AM
Pete Wright
Pete Wright - avatar
+ 1
Pete Wright Lol nope i saving up for a new one anyhow i do like your code as well that is my goal
3rd Mar 2019, 2:05 AM
Brennan Woodroof
Brennan Woodroof - avatar
+ 1
Pete Wright while looking over your code there are parts ive never seen before like the .substr() which i looked up and im glad to have come acrossed it as its something i needed in another code awhile back in another code but i have to ask why the $ signs as haven't seen them before as i am self taught alot of the fundamental is lost as i try to learn throw various tutorial mainly from w3schools and some from this app due to this app dont cover it enough or dont cover it all that the particular element has
3rd Mar 2019, 3:25 AM
Brennan Woodroof
Brennan Woodroof - avatar
+ 1
Brennan Woodroof let me explain: The '
#x27; sign is just the name of the function. I could have written 'element' instead, but I have chosen the '
#x27; for two reasons: 1. To keep the code as short as possible 2. To have a similar notation to jQuery The $ function works as follows: It takes the parameter (which is the ID of the element I want to use) and returns the element as a HTML object which then has all properties and methods of an HTML DOM element, e.g.: 'value' So $("id").value is the same as: document.getElementById("id").value and $("id").innerHTML is the same as document.getElementById("id").innerHTML which sets or returns the HTML of the selected element. Hope this helps
3rd Mar 2019, 4:55 AM
Pete Wright
Pete Wright - avatar
0
Give me some time, I will try out few things...
3rd Mar 2019, 12:13 AM
Pete Wright
Pete Wright - avatar