Action Directory / Journal Entry

Install

Inserts date and time as a Markdown header at the top of your document

Shared by Michał

Script

// Inserts day, date and 12 hr time as a heading at the beginning of your document. Also inserts
// new line to start typing your log notes. Based on the Log action for 1Writer.

// Format day. e.g. Sunday Feb 7, 2016
var now = new Date();
var hh = now.getHours();
var min = now.getMinutes();
var dd = now.getDate();
var mm = now.getMonth()+1;
var yyyy = now.getYear()+1900;
var dayOfWeek = now.getDay();
var MonthNames = ["stycznia", "lutego", "marca", "kwietnia", "maja", "lipca", "czerwca", "sierpnia", "września", "października", "listopada", "grudnia"
];
var daysOfWeek = new Array("niedziela", "poniedziałek", "wtorek", "środa", "czwartek", "piątek", "sobota");
var day = daysOfWeek[dayOfWeek];

var today = day + ', ' + now.getDate() + ' ' + MonthNames[now.getMonth()] + ' ' + yyyy;

// Format time. e.g. 7:12am
if(hh<12) {
    min=min+'am'
} else {
    min=min+'pm'
}

if(hh>=13) {
    hh=hh-12
}

var time = hh+':'+min;

// Insert date & time at beginning of document as a Markdown header and position cursor just after heading so that you're ready to type.
var heading = '### ' + today + '\n\n\n';
editor.replaceTextInRange(0, 0, heading);
editor.setSelectedRange(heading.length-2, heading.length-2);