Action Directory / Add Log Entry (time only)

Install

Append header with current time at end of file

Shared by Bernhard

Script

// Insert 24h time at end of file
function appendLogEntry(prefix) {

function pad2(str){ 
 return ('0' + str).slice(-2);
}
function cursorToEnd() {
  var content = editor.getText();
  editor.setSelectedRange(content.length);
}
var now = new Date();
entry  = prefix
         + pad2(now.getHours()) + ':' 
         + pad2(now.getMinutes()) +' \n\n';
cursorToEnd();
editor.replaceSelection(entry);
cursorToEnd();

}

appendLogEntry('## ');