忍者ブログ

★黒猫宅急便★ver.2

( *´艸`) いらっしゃいまし。



[1247]  [1268]  [1339]  [1246]  [1253]  [1245]  [1244]  [1243]  [1250]  [1249]  [1240

entry_top_w.png
結構前に、曜日の算出C言語でやったときは、結構苦戦したような……確かカレンダーを作った時だったかな?(懐かしいw)


Javascript 曜日の算出をする機会があったので、やってみたんだけど、一から曜日を計算したりしなくていいので、なんか楽チンだったなぁ~♪

こんな感じ!?
生年月日を選択して、計算ボタンを押してみよう!




今回のスクリプトは……
----------  ここから ----------

function KURONEKO(){

 weeks = new Array("日", "月", "火", "水", "木", "金", "土");

 temp_year = document.getElementById("year").selectedIndex;
 temp_year = document.getElementById("year").options[temp_year].text;
 
 temp_month = document.getElementById("month").selectedIndex;
 temp_month = document.getElementById("month").options[temp_month].text;

 temp_day = document.getElementById("day").selectedIndex;
 temp_day = document.getElementById("day").options[temp_day].text;

 switch(temp_month){
 case "2":
  days_limit = 28;
    if( (temp_year % 4) == 0 &&  (temp_year % 100) != 0 || (temp_year % 400) ==0){
      days_limit = 29;
    }
  break;

 case "4":
 case "6":
 case "9":
 case "11":
    days_limit = 30;
    break;
 
 default:
   days_limit = 31;
 }

 if(temp_day > days_limit){
    if(temp_month == 2){
       alert(temp_year + "年の" + temp_month + "月は、" + days_limit + "日までです!");
       return;
    }
  alert(temp_month + "月は、" + days_limit + "日までです!");
  return;
 }
 temp_date = new Date(temp_year, temp_month - 1, temp_day);
 temp_weeks = temp_date.getDay();
 
  alert(temp_year + "年" + temp_month + "月" + temp_day + "日は、" + weeks[temp_weeks] + "曜日デス");
}

----------  ここまで ----------
 
 



ランキング参加中!
ブログランキング・にほんブログ村へ
entry_bottom_w.png

この記事にコメントする

お名前
コメントタイトル
色変更
URL
コメント本文
パスワード Vodafone絵文字 i-mode絵文字 Ezweb絵文字



この記事へのトラックバック

この記事にトラックバックする:
plugin_top_w.png
かうんたー


現在の閲覧者数:
plugin_bottom_w.png
plugin_top_w.png
きじ検索
plugin_bottom_w.png
plugin_top_w.png
記事らんきんぐ

plugin_bottom_w.png
plugin_top_w.png
広告


plugin_bottom_w.png
plugin_top_w.png
その他


参加中
ブログランキング・にほんブログ村へ
plugin_bottom_w.png
plugin_top_w.png
あくせすらんきんぐ
plugin_bottom_w.png
plugin_top_w.png
ぷろふぃーる
HN:黒猫★
年齢:2さい
性別:♂オス
生誕:5月25日(日)
職業:魔女の子分
趣味:倶楽部活動

plugin_bottom_w.png
plugin_top_w.png
最新こめんと
[10/03 30bB]
[02/13 ★黒猫★]
[01/29 のら猫]
[11/04 ★黒猫★]
[11/03 ゆーき]
plugin_bottom_w.png
plugin_top_w.png
広告3
plugin_bottom_w.png
plugin_top_w.png
ブログ ver.4
plugin_bottom_w.png

PR


Copyright ★黒猫宅急便★ver.2 by ★黒猫★ All Rights Reserved.
忍者ブログ [PR]