Skip to content

Instantly share code, notes, and snippets.

@nsuvorov83
Created October 11, 2021 15:53
Show Gist options
  • Select an option

  • Save nsuvorov83/e4e4a2d7074d1b15b5fe4ad5efffaf28 to your computer and use it in GitHub Desktop.

Select an option

Save nsuvorov83/e4e4a2d7074d1b15b5fe4ad5efffaf28 to your computer and use it in GitHub Desktop.
function forEveryCell(sheet, ra, func) {
/*
* Осуществляет вызов func для каждой ячейки диапазона ra на листе sheet
*
* Пример вызова:
* forEveryCell("deals", "G3:G", function (cell) {Logger.log(cell.getValue())});
*
*/
var range = SpreadsheetApp.getActive().getSheetByName(sheet).getRange(ra);
var rows = range.getNumRows();
var rowsArray = new Array(rows).fill(true).map((e, i) => i+1);
rowsArray.forEach(function(row) {
var cell = range.getCell(row,1);
func(cell);
});
}
function dateDifference(a, b) {
//Определяет разницу дат в мс
const aEpoch = +new Date(a);
const bEpoch = +new Date(b);
const maxEpoch = Math.max(aEpoch, bEpoch);
const minEpoch = Math.min(aEpoch, bEpoch);
return maxEpoch - minEpoch;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment