<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>日数チェッカー</title>
</head>
<body>
<h1>日数チェッカー</h1>
<pre>
----------------------------
平成25年<span id="todayDate">hoge</span>
----------------------------
<span id="todayPrjDate">hoge</span>日目
(四半期残 <span id="todayQtRestDate">fuga</span>日 / 残<span id="todayPrjRestDate">hoge</span>日)
----------------------------
</pre>
<script>
var t = new Date();
var todaySec = t.getTime();
var week = new Array("日","月","火","水","木","金","土");
var today = (t.getMonth() + 1) + "月" + t.getDate() + "日";
var e = document.getElementById('todayDate');
e.innerHTML = today;
var basePrjDate = new Date(2012,11-1,2);
var basePrjSec = basePrjDate.getTime();
var diffPrjSec = todaySec - basePrjSec;
var diffPrjDate = Math.floor(diffPrjSec / (1000*60*60*24));
var todayPrjDate = diffPrjDate;
var ep = document.getElementById('todayPrjDate');
ep.innerHTML = todayPrjDate;
var todayPrjRestDate = 1000 - todayPrjDate;
var erp = document.getElementById('todayPrjRestDate');
erp.innerHTML = todayPrjRestDate;
function getMonthEndDay(year, month){
var day = new Date(year, month, 0);
return day.getDate();
}
switch (t.getMonth() + 1) {
case 1:
case 2:
case 3:
var q1day = getMonthEndDay(2013, 1) + getMonthEndDay(2013, 2) + getMonthEndDay(2013, 3);
var q1StartDay = new Date(2013, 1-1, 1);
var q1StartSec = q1StartDay.getTime();
var q1DiffSec = todaySec - q1StartSec;
var q1DiffDate = Math.floor(q1DiffSec / (1000*60*60*24));
var q1RestDate = (q1day - 1) - q1DiffDate;
var eqrp = document.getElementById('todayQtRestDate');
eqrp.innerHTML = q1RestDate;
break;
case 4:
case 5:
case 6:
var q1day = getMonthEndDay(2013, 4) + getMonthEndDay(2013, 5) + getMonthEndDay(2013, 6);
var q1StartDay = new Date(2013, 4-1, 1);
var q1StartSec = q1StartDay.getTime();
var q1DiffSec = todaySec - q1StartSec;
var q1DiffDate = Math.floor(q1DiffSec / (1000*60*60*24));
var q1RestDate = (q1day - 1) - q1DiffDate;
var eqrp = document.getElementById('todayQtRestDate');
eqrp.innerHTML = q1RestDate;
break;
}
</script>
</body>
</html>