I recently switched to the V8 Runtime in Google Apps Script and I'm having a strange problem. (Which I can't seem to reproduce in a minimal format.)
My Google Sheet allows users to enter (in cells) a 'work_start' time and a 'work_end' time. For now I have chosen "9:30" and "18:00". With the old Runtime this becomes:
- Sat Dec 30 1899 09:30:00 GMT+0009 (Central European Standard Time)
- Sat Dec 30 1899 18:00:00 GMT+0009 (Central European Standard Time)
When I switch to the V8 Runtime, however, I get this:
- Sat Dec 30 1899 08:39:21 GMT+0009 (Central European Standard Time)
- Sat Dec 30 1899 17:09:21 GMT+0009 (Central European Standard Time)
If I run it again immediately, with the old runtime, it goes back to 9:30 and 18:00.
I have checked my code multiple times and I set these values once (as globals) but I never change them. I only use/read them. I even set a breakpoint on the first line of my main function.
I set up a new project and tried to recreate the problem, but for some reason the problem doesn't occur in a new sheet. I have also tried clearing the formatting of those two cells.
Next, I tried one last thing. I moved the code out of the global space and put it in a function, then had a breakpoint on the next line so I could check my variables:
function Main() {
var work_start = cal.getRange("G1").getValue(); // work start time
var work_end = cal.getRange("G2").getValue(); // work end time
var test = 0; // SET A BREAKPOINT HERE
...
}
This gives me the same strange results: 8:39:21 and 17:09:21. (Again, only when part of my program. In a new sheet it gives 9:30 and 18:00, as expected.)
Not even sure how to begin to look for an answer to this bug, so any help or guidance will be appreciated.