Note that it doesn’t convert minutes so if you, for example, add 45 minutes to 45 minutes, you’ll get ___:90.
In terms of explanation, it’s taking the text string such as “23:15” and making it into a list by breaking up the string using the “:” as a delimiter. So in that case, the resulting list contains {“23”,“15”}. I then reference the #1 item of the list which is “23” and add it to the #2 item of the list which is “15” to get 38.
You can see it in action in the same demo project (find the screen with your name). Note that it’s just pulling the time values from the two labels at the bottom of the screen… it’s not connected to the other coding I did for you before on that screen.
How about this? I separate the user’s time input fields into two lists called “report hr list” and “report min list”. "LattHour text is converted to minutes (* by 60). Assuming the user inputs the hour, then the minute, the “report min list” triggers the next block that sets app variable “lattminutes” by adding the new values in “LattHour” and “LattMin”. To convert back to hours, I divide by 60 and get hours and fraction. Using the decimal as a delimiter, i multiply the number after the decimal by 60 to convert back to minutes and join them. That’s the concept. After testing, what happens is that if I enter 1 hour and 5 minutes, the result is 1.499999999. It is doing the math correctly, but it is returning a number delimited by a decimal where I want a colon, and it is not rounding .4999999 to 5, and it is not placing the leading zero in front of the 5 (as written in the “report min list” to make it look like 1:05.
Looks like a good plan. I don’t understand why you’re multiplying the decimal value by 6 though. If you had 66 minutes and you divide by 60 to get 1.1 hours, then you’d multiply the 0.1 hours by 60 to get 6 minutes.
It’s fine to use the list blocks for separating out decimal values as long as you keep in mind that you’re working with text strings so you don’t technically have numbers until you use a math operation (e.g. +, -, x, ÷) on them.
Often, the math blocks themselves will do what you need in a simpler way. For example, you can use the remainder block to divide 66 by 60 and get 6 as the number of minutes.
One way is not “better” than the other. It just depends what makes sense to you as a programmer.
I am trying to take a number like 3.14159265 and set the decimal point as the delimiter. I can split the number into a 3 and the infinitely large number 14159265… I want the second number to be 14, just the first two digits in the number. How can this be done?
I think it’s best to add this kind of question to the topic you’ve already contributed to since it has details about the what/why/how of this issue and provides context.
Not a big deal! Just figured it helps people to know the backstory instead of having to ask you the same questions again. Glad you’re making progress on this.
Down to the last hurdle. Shown is the DB from which a user selects an “FDP Start” time window using a list. If the user reports to work at 0500 local time, then row 3 is selected and the program runs properly. The problem is that if the user lives in SFO, the program needs to enter the row corresponding to the user’s body-clock time, not their local time. There are app user inputs for body clock and local time, so I have the information, but I’m not sure how to modify the input to the DB so that it references the correct row. Attached is the DB I made to come up with a correction to the input time, but I can’t figure out how to work that into a solution.
When you have a row id and you use the green index block (or a variable if that’s the case) for the row number, just use a math block to add the amount in the Base Time Zone table to it.
The top database is “FAR 117 FDP.” The bottom one is “FDP Correction.” If I do this, I think it simply changes the row ID by the correction amount. That doesn’t work since the FDP Start columns aren’t in equal increments. Eg is the FDP time is 1900, and the correction is -1, then the new time is 1800 which is still in row 8, so no correction. I believe you are telling me to correct from row 8 to row 7, but that wouldn’t yield the proper result.