Created
October 11, 2021 15:53
-
-
Save nsuvorov83/e4e4a2d7074d1b15b5fe4ad5efffaf28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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