I'm using Google Spreadsheets and I have a sheet in the following format:
Start | End | Partial result | Expected | Total
08:00 | 12:00 | 04:00 | 05:00 | -01:00
14:00 | 18:00 | 04:00 | 05:00 | -01:00
----------------------------------------------------
| Month tot| -02:00
As you can see, it allows for negative duration stamps. This is causing me a lot of trouble in Google Scripts.
I want to email everyone a monthly summary.
Here's a simple snippet:
var sheet = SpreadsheetApp.getActive().getSheetByName(...);
var monthlyTotal = sheet.getRange(1, 1).getValue(); //The total is at cell A1
Now, when I debug, it shows my monthlyTotal as a Date
object, set to Tue Dec 26 1899 14:50:28 GMT-0300 (BRT)
(this is quite correct, my result is -81:16:00
, it subtracted 81:16
from 1970-01-01 00:00:00
, no issues there).
Now, I have no idea how to get back to a duration format (-81:16
). I have tried converting this date object to a negative timestamp, but +monthlyTotal
returns what I believe to be a wrong value (-2212132172000
).
I have no idea how to turn a Date
object from before 1970 to a timestamp and, as a consequence, I don't know how to proceed.