I'd love to have others weigh in on this too.
If he's using that code in his app, as long as he doesn't claim it's part of his abstraction AND he doesn't claim it's his main algorithm, I think it would be okay. Obviously safer if this code isn't included in the algorithm portion that he highlights for the written responses at all. Like for example if this is his way of "including mathematical concepts" I would worry about him saying it came from someone else. Not saying he can't just feels risky.
FWIW he could probably recreate this code himself without copying. It's pretty standard fare. A few translations:
That code snippet looks a little incomplete -- don't know what
time variable holds.
Anyway to recreate you need to know the app lab function:
getTime() returns the number of milliseconds since midnight, jan 1, 1969. (see docs)
Once you know that, the rest is math to figure out what you want about the time.
Math.floor simply returns the whole number portion of a decimal number regardless of how big the decimal portion is.
Math.floor(23.99999) --> 23
% is the modulo operator which returns the remainder from division. (see unit 4 lesson 7). I assume that
time is just the result of
getTime(). When you do %86400 you're dividing a big number by 86400 and getting the remainder. Since 86400 is the number of seconds in a day, I assume this is an attempt to extract the number of seconds (or miliseconds) that have elapsed so far today. I'll need to check my math on that. (I realize this isn't a great explanation of why this works, but that's what it's doing).
? thing is a short way to do an if-statement (that most people think is ugly and makes code hard to read). loosely speaking this:
(correct ? timeZoneCorrection : 0) means: if
correct is true, then use
timeZoneCorrection else use
0. It would take more lines of code to use an if-statement to do the arithmetic for that single line, but would also be much more readable.
I also assume that getTime() returns the time based on wherever the amazon server cluster is that runs applab. So
timezoneCorrection is probably just a number to shift the result some number of hours to meet local context.
hope that helps.