본문 바로가기

HTML, JAVASCRIPT

카렌다

<style type="text/css">
<!--
td {font-size: 10pt}
-->
</style>

<script language="JavaScript">
<!--

function chgYYYY(myYear) { return (myYear< 2000) ? 1900 + myYear : myYear; }

function writeCal() {
 var output = '';
 var to_Dymd= new Date();
 var c_Y = chgYYYY(to_Dymd.getYear());
 var c_M = to_Dymd.getMonth();
 var c_D = to_Dymd.getDate();
 var c_YM = c_Y*100 + c_M;
 var year_range = c_Y + 1;
 var yobi = new Array(7);
 var jmonth= new Array(12);
 var days= new Array(12);
 var o_YM;
 var valMonth;
 var firstDay ;
 var startDay;
 
 yobi[0] = "<font color=#FF0000>日</font>"; yobi[1] = "月"; yobi[2] = "火"; yobi[3] = "水"; yobi[4] = "木"; yobi[5] = "金"; yobi[6] = "土";
 
 jmonth[0] = "1";jmonth[1] = "2";jmonth[2] = "3";jmonth[3] = "4";jmonth[4] = "5";jmonth[5] = "6";
 jmonth[6] = "7";jmonth[7] = "8";jmonth[8] = "9";jmonth[9] = "10";jmonth[10] = "11";jmonth[11] = "12";

 days[0] = "31";days[1] = "28";days[2] = "31";days[3] = "30";days[4] = "31";days[5] = "30";
 days[6] = "31";days[7] = "31";days[8] = "30";days[9] = "31";days[10] = "30";days[11] = "31";
 
 output += '<td><span class="s3">' + c_Y + '年' +  jmonth[c_M] + '月' + '</span></td>';
 output += '</tr>';
 output += '<tr>';

 firstDay = new Date(c_Y,c_M,1);
 startDay = firstDay.getDay();

 if (((c_Y % 4 == 0) && (c_Y % 100 != 0)) || (c_Y % 400 == 0))
  days[1] = 29;
 else
  days[1] = 28;

 output += '<td valign="top" align="center"><table border="0" cellpadding="0" cellspacing="0" ><tr> <td colspan="3" bgcolor="#663300" height="1"></td></tr><tr> <td width="1" bgcolor="#663300"></td><td bgcolor="#999999"> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#999999"><tr align="center" bgcolor="#CCCCCC" class="s3"> ';

 for (j=0; j<7; j++)
  output += '<td><strong>' + yobi[j] +'</strong></td>';

 output += '</tr><tr align="center" bgcolor="#FFFFFF" class="s3"> ';

    var column = 0;
    var lastMonth = c_M - 1;
    if (lastMonth == -1)
  lastMonth = 11;

    for (j=0; j<startDay; j++, column++)
        output += '<td><font color="#CCCCCC">' + (days[lastMonth]-startDay+j+1) + '</font></td>';

    for (j=1; j<=days[c_M]; j++, column++)
 {
  H1=-1; H2=-1; H3=-1;
  switch (c_M)
  {
   case 0: H1=1; H2=14-(startDay+5)%7; break;
   case 1: H1=11; break;
   case 2: H1=parseInt(0.24242*c_Y-parseInt(c_Y/4+'')+35.84); break;
   case 3: H1=29; break;
   case 4: H1=3; H2=4; H3=5; break;
   case 6: if(c_Y<2003) H1=20; else H1=21-(startDay+5)%7; break;
   case 8: H3=parseInt(0.24204*c_Y-parseInt(c_Y/4)+39.01);
   if(c_Y<2003)
   {
    H1=15;
   }
   else
   {
    H1=21-(startDay+5)%7;
    if(H1+2 == H3)
     H2=H1+1;
   }
   break;
   case 9: H1=14-(startDay+5)%7; break;
   case 10: H1=3; H2=23; break;
   case 11: H1=23; break;
   default: break;
  }
 
  if (column==0 || j==H1 || j==H2 || j==H3)
   aclass = '<font color=#FF0000>' + j + '</font>';
  else if (column==1 && (j==H1+1 || j==H2+1 || j==H3+1))
   aclass = '<font color=#FF0000>' + j + '</font>';
  else if (column==6 || j==H1 || j==H2 || j==H3)
   aclass = '<font color=#FF0000>' + j + '</font>';
  else
   aclass = '<font color=#000000>' + j + '</font>';
 
  output += '<td>';
 
  if ((c_YM==c_YM) && (j==c_D))
  {
   output += '<b>' + aclass + '</b></td>';
  }
  else
  {
   output += aclass + '</td>';
  }

  if (column == 6)
  {
   if(j != days[c_M])
   {
    output += '</tr><tr align="center" bgcolor="#FFFFFF" class="s3"> ';
    column = -1;
   }
   else
    column = -1;
  }
 }

 if (column > 0)
 {
  for (j=1; column<7; j++, column++)
   output +=  '<td><font color="#CCCCCC">' + j + '</font></td>';
 }

 output += '</tr></table></td><td width="1" bgcolor="#663300"></td></tr><tr> <td colspan="3" bgcolor="#663300"></td></tr></table></td>';

 return output;
}

//-->
</script>

<center>
 <table border="0" cellspacing="1" cellpadding="3">
  <tr>
   <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
     <tr>
      <td bgcolor="#CCCCCC" nowrap><span class="s4"><strong>カレンダー</strong></span></td>
     </tr>
     <tr>
      <td height="10"> </td>
     </tr>
    </table>
    <table width="" border="0" cellpadding="1" cellspacing="0">
     <tr>
      <script language="JavaScript"><!--
       document.write(writeCal());
      //--></script>
     </tr>
    </table>
   </td>
  </tr>
 </table>
</center>