Skip to content

Instantly share code, notes, and snippets.

@dulichan
Created April 14, 2014 16:01
Show Gist options
  • Save dulichan/10661092 to your computer and use it in GitHub Desktop.
Save dulichan/10661092 to your computer and use it in GitHub Desktop.
A Google Script for spreadsheets to covert a selection of cells to mins:secs
function sensible_time() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getActiveRange().getValues();
for (var i = 0; i < data.length; i++) {
for (var j = 0; j < data[i].length; j++) {
if (data[i][j]) {
var range = sheet.getRange(24+i, j+1);
time = data[i][j];
var mins = ~~(time / 60);
var secs = time % 60;
Logger.log(mins+":"+secs+"");
range.setValue(mins+":"+secs);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment