egoist
12/25/2014 - 10:57 PM

getTitle.js

function getTitle(weekday){
  var t = new Date();
  t = t.getDay();
  var title = '';
  switch(weekday){
    case 1:
      title = '周一';
      break;
    case 2:
      title = '周二';
      break;
    case 3:
      title = '周三';
      break;
    case 4:
      title = '周四';
      break;
    case 5:
      title = '周五';
      break;
    case 6:
      title = '周六';
      break;
    case 7:
      title = '周日';
      break;
  }
  if(weekday = t) title += '<small>今天</small>';
  if(weekday = t-1) title += '<small>昨天</small>';
  if(weekday = t-2) title += '<small>前天</small>';
  if(weekday = t+1) title += '<small>明天</small>';

  if(weekday = t+2) title += '<small>后天</small>';
  return title;
}