(function torinoichi(){ var today = new Date(); var year = document.getElementById('year').selectedIndex = today.getFullYear()-1900; year += 1900; var leap = Math.floor(year/4)-Math.floor(year/100)+Math.floor(year/400); var ved = Math.floor(20.8431+0.242194*(year-1980))-Math.floor((year-1980)/4); var d12 = ((year-1900-leap)*365+leap*366+ved+5)%12; document.getElementById('day').selectedIndex=ved-d12-6-Math.floor((11-d12)/10)*12+Math.floor((d12+5)%12/7)*2; document.getElementById('year').onchange = function(){changeday()}; document.getElementById('day').onchange = function(){changeday()}; onchange=function changeday(){ var year = document.getElementById('year').selectedIndex+1900; var leap = Math.floor(year/4)-Math.floor(year/100)+Math.floor(year/400); var ved = Math.floor(20.8431+0.242194*(year-1980))-Math.floor((year-1980)/4); var d12 = ((year-1900-leap)*365+leap*366+ved+5)%12; document.getElementById('day').selectedIndex=ved-d12-6-Math.floor((11-d12)/10)*12+Math.floor((d12+5)%12/7)*2; }})();