date
Insert the date, day of the week can be calculated a few days ago.

Script key: Insert the date, day of the week can be calculated a few days ago.

Posted by @feelingplace

Install

Details

Label date
Voice Over Insert the date, day of the week can be calculated a few days ago.
Script
//Please start by selecting the number of days before or numbers.

var daysBefore = getSelectedText();
var addDays = -daysBefore;
var nowdate = new Date();
var year = nowdate.getFullYear();
var month = nowdate.getMonth() + 1;
var date = nowdate.getDate();
function computeDate(year, month, day, addDays) {
  dt = new Date(year, month - 1, day);
  baseSec = dt.getTime();
  addSec = addDays * 86400000;
  targetSec = baseSec + addSec;
  dt.setTime(targetSec);
  return dt;
    }
beforeDate = computeDate(year, month, date, addDays);
var week = new Array("日", "月", "火", "水", "木", "金", "土");
var dayOfWeek = week[beforeDate.getDay()];
var buf = beforeDate.getFullYear() + "年" + (beforeDate.getMonth() + 1) + "月" + beforeDate.getDate() + "日(" + dayOfWeek + ")";
var selRange = getSelectedRange();
setSelectedText(buf);
setSelectedRange(selRange[0]+buf.length, 0);

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus