<%@ page language="java" pageEncoding="gbk"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<html>
<head>
<title>计算页面</title>
<style type="text/css">
<!--
body {
background-image: url(image/xiaoxiang.jpg);
background-attachment: fixed;
background-repeat: repeat-x;
}
-->
</style>
</head>
<%
String year=request.getParameter("year");
String month=request.getParameter("month");
String day=request.getParameter("day");
String hours=request.getParameter("hours");
String minute=request.getParameter("minute");
String second=request.getParameter("second");
%>
<!------------------------------------------------------------------>
<!-- 计算您属相的代码 -->
<!------------------------------------------------------------------>
<%
int toyear=1984;
String birthyear1=year;
int birthyear=Integer.parseInt(birthyear1);
String birthpet="";
int x=(toyear-birthyear)%12;
if(Integer.toString(birthyear)!=null){
if((x == 0)){
birthpet="您属鼠" ;
}
else{
if((x == 1)||(x == -11)){
birthpet="您属牛" ;
}
else{
if((x == 2) || (x == -10)){
birthpet="您属虎" ;
}
else{
if((x == 3)||(x == -9)){
birthpet="您属兔";
}
else{
if((x == 4)||(x == -8)){
birthpet="您属龙";
}
else{
if((x == 5)||(x == -7)){
birthpet="您属蛇";
}
else{
if((x == 6)||(x == -6)){
birthpet="您属马";
}
else{
if((x == 7)||(x == -5)){
birthpet="您属羊";
}
else{
if((x == 8)||(x == -4)){
birthpet="您属猴";
}
else{
if((x == 9)||(x == -3)){
birthpet="您属鸡";
}
else{
if((x == 10)||(x == -2)){
birthpet="您属狗";
}
else{
if((x == 11)||(x == -1)){
birthpet="您属猪";
}
}
}
}
}
}
}
}
}
}
}
}
}else{
birthpet="请输入你的出生年份";
}
%>
<!------------------------------------------------------------------>
<!------------------------------------------------------------------>
<!-- 计算您星座的代码 -->
<!------------------------------------------------------------------>
<%
String xingzuo;
int xmonth=Integer.parseInt(month);
int xday=Integer.parseInt(day);
if( (1==xmonth && xday>=21 && xday<=31) || (2==xmonth && 1<=xday&&xday<=18) ){
xingzuo="水瓶座";
}
elseif( (2==xmonth && xday>=19 && xday<=29) || (3==xmonth && 1<=xday&&xday<=20) ){
xingzuo="双鱼座";
}
elseif( (3==xmonth && xday>=21 && xday<=31) || (4==xmonth && 1<=xday&&xday<=20) ){
xingzuo="白羊座";
}
elseif( (4==xmonth && xday>=21 && xday<=30) || (5==xmonth && 1<=xday&&xday<=21) ){
xingzuo="金牛座";
}
elseif( (5==xmonth && xday>=22 && xday<=31) || (6==xmonth && 1<=xday&&xday<=21) ){
xingzuo="双子座";
}
elseif( (6==xmonth && xday>=22 && xday<=30) || (7==xmonth && 1<=xday&&xday<=22) ){
xingzuo="巨蟹座";
}
elseif( (7==xmonth && xday>=23 && xday<=31) || (8==xmonth && 1<=xday&&xday<=23) ){
xingzuo="狮子座";
}
elseif( (8==xmonth && xday>=24 && xday<=31) || (9==xmonth && 1<=xday&&xday<=22) ){
xingzuo="处女座";
}
elseif( (9==xmonth && xday>=23 && xday<=30) || (10==xmonth && 1<=xday&&xday<=23) ){
xingzuo="天秤座";
}
elseif( (10==xmonth && xday>=24 && xday<=31) || (11==xmonth && 1<=xday&&xday<=22) ){
xingzuo="天蝎座";
}
elseif( (11==xmonth && xday>=23 && xday<=30) || (12==xmonth && 1<=xday&&xday<=21) ){
xingzuo="射手座";
}
elseif( (12==xmonth && xday>=22 && xday<=31) || (1==xmonth && 1<=xday&&xday<=20) ){
xingzuo="摩羯座";
}
else{
xingzuo="日期错误!";
}
%>
<body OnLoad="startclock()">
<center>
<p><br><p><br><p><br><p><br><p><br><p><br>
<!-------------------- 接收您的出生日期 ---------------->
<form name="chushengri">
您的出生日期:
<textarea name="year0" cols="12" rows="1" readonly ><%= year %></textarea>年
<textarea name="month0" cols="12" rows="1" readonly ><%= month %></textarea>月
<textarea name="day0" cols="12" rows="1" readonly ><%= day %></textarea>日<br>
您的出生时间:
<textarea name="hours0" cols="12" rows="1" readonly ><%= hours %></textarea>时
<textarea name="minute0" cols="12" rows="1" readonly ><%= minute %></textarea>分
<textarea name="second0" cols="12" rows="1" readonly ><%= second %></textarea>秒<p>
您的属相:<textarea name="shuxiang" cols="12" rows="1" readonly ><%= birthpet %></textarea>
您的星座:<textarea name="xingzuo" cols="12" rows="1" readonly ><%= xingzuo %></textarea>
</form>
<!----------------------------------------------------------------->
<!-- 以下是用于计算的脚本代码 -->
<!----------------------------------------------------------------->
<script type="text/javascript">
<!-- Begin
/*--------------------获取出生日期------------------------**/
var byear = document.chushengri.year0.value;
var mm = document.chushengri.month0.value;
var bday = document.chushengri.day0.value;
var bhours = document.chushengri.hours0.value;
var bminute = document.chushengri.minute0.value;
var bsecond = document.chushengri.second0.value;
/**-------------------------------------------------------*/
var year = new Date();
var year2 = year.getYear();
var year3 = (year < 2000) ? year2 + 1900 : year2;
//-----------计算出岁数----------------------------------
thedate = new Date();
yy2 = thedate.getYear();
mm2 = thedate.getMonth() + 1;
dd2 = thedate.getDate();
if (yy2 < 100) yy2 += 1900
var yourage = yy2 - byear;
if (mm2 < mm) yourage--;
if ((mm2 == mm) && (dd2 < bday)) yourage--;
//-------------------------------------------------------
TMonth = new Array(
'January','February','March',
'April','May','June','July',
'August','September','October',
'November','December'
);
CurMonth = mm - 1;
var bmonth = TMonth[CurMonth];
var age2 = yourage + 1;//岁数加1,下一年几岁
var timerID;
var timerRunning = false;
var today = new Date();
var startday = new Date();
var enday = new Date();
var secPerDay = 0;
var minPerDay = 0;
var hourPerDay = 0;
var secsLeft = 0;
var secsRound = 0;
var secsRemain = 0;
var minLeft = 0;
var minRound = 0;
var minRemain = 0;
var timeRemain = 0;
/*-------------------------------------------------------------------------------------------------*/
function stopclock() {
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
/*---------------------页面初始化跳用 函数-----------------------------------------------------------*/
function startclock() {
stopclock();
showtime();
showtime1();
}
/*--------------------------------------------------------------------------------------------------*/
//--------------------计算下一岁生日的倒计时 函数---------------------------------------------------------
function showtime() {
today = new Date();//创建当前时期变量
enday = new Date(""+bmonth+", "+bday+" "+year3+" 00:00");//获取出生日期
enday.setYear(""+year3+"");
enday.setMonth(mm-1);
enday.setDate(bday);
enday.setHours(bhours);
enday.setMinutes(bminute);
enday.setSeconds(bsecond);
secsPerDay = 1000 ; //毫秒
minPerDay = 60 * 1000 ;//一分钟有多少毫秒
hoursPerDay = 60 * 60 * 1000;//一小时有多少毫秒
PerDay = 24 * 60 * 60 * 1000;//一天有多少毫秒
//-----------计算出离下一岁生日的 秒数------------------------------------------------------------------
secsLeft = (enday.getTime() - today.getTime()) / minPerDay;
secsRound = Math.round(secsLeft);
secsRemain = secsLeft - secsRound;
secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain = (secsLeft - secsRound) * 60;
secsRemain = Math.round(secsRemain);
//------------------------------------------------------------------------------------------------------
//-----------计算出离下一岁生日的 分钟数-----------------------------------------------------------------
minLeft = ((enday.getTime() - today.getTime()) / hoursPerDay);
minRound = Math.round(minLeft);
minRemain = minLeft - minRound;
minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain =((minLeft - minRound) * 60);
minRemain = Math.round(minRemain - 0.495);
//------------------------------------------------------------------------------------------------------
//-----------计算出离下一岁生日的 小时数-----------------------------------------------------------------
hoursLeft = ((enday.getTime() - today.getTime()) / PerDay);
hoursRound = Math.round(hoursLeft);
hoursRemain = hoursLeft - hoursRound;
hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24) :hoursRemain = ((hoursLeft - hoursRound) * 24);
hoursRemain = Math.round(hoursRemain - 0.5);
//------------------------------------------------------------------------------------------------------
//-----------计算出离下一岁生日的 天数-------------------------------------------------------------------
daysLeft = ((enday.getTime() - today.getTime()) / PerDay);
daysLeft = (daysLeft - 0.5);
daysRound = Math.round(daysLeft);
daysRemain = daysRound;
//------------------------------------------------------------------------------------------------------
if (daysRemain == 1) day_rem = " 天 "
else day_rem = " 天 "
if (hoursRemain == 1) hour_rem = " 小时 "
else hour_rem = " 小时 "
if (minRemain == 1) min_rem = " 分钟 "
else min_rem = " 分钟 "
if (secsRemain == 1) sec_rem = " 秒"
else sec_rem = " 秒"
//---------完整的显示语句---------------------------------------------------------------------------------
timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain + min_rem + secsRemain + sec_rem;
document.down.face.value = timeRemain;//给文本框传递数值
timerID = setTimeout("showtime()",1000);
timerRunning = true;
if (daysRemain < 0) year3 = year3 + 1
}
//--------------------计算出你在世上的存活时间的计时 函数------------------------------------------------------
function showtime1() {
startday = new Date(""+bmonth+" "+bday+", "+byear+" 00:00 EDT");
startday.setYear(""+byear+"");
//startday.setMonth(mm);
//startday.setDate(bday);
startday.setHours(bhours);
startday.setMinutes(bminute);
startday.setSeconds(bsecond);
today = new Date();
secsPerDay = 1000 ;//毫秒
minPerDay = 60 * 1000 ;//一分钟有多少毫秒
hoursPerDay = 60 * 60 * 1000;//一小时有多少毫秒
PerDay = 24 * 60 * 60 * 1000;//一天有多少毫秒
//-----------计算出你在世上存活的 秒数------------------------------------------------------------------
secsLeft = (today.getTime() - startday.getTime()) / minPerDay;
secsRound = Math.round(secsLeft);
secsRemain = secsLeft - secsRound;
secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain =(secsLeft - secsRound) * 60;
secsRemain = Math.round(secsRemain);
//-----------计算出你在世上存活的 分钟数------------------------------------------------------------------
minLeft = ((today.getTime() - startday.getTime()) / hoursPerDay);
minRound = Math.round(minLeft);
minRemain = minLeft - minRound;
minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain =((minLeft - minRound) * 60);
minRemain = Math.round(minRemain - 0.495);
//-----------计算出你在世上存活的 小时数------------------------------------------------------------------
hoursLeft = ((today.getTime() - startday.getTime()) / PerDay);
hoursRound = Math.round(hoursLeft);
hoursRemain = hoursLeft - hoursRound;
hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24);
hoursRemain = Math.round(hoursRemain - 0.5);
//-----------计算出你在世上存活的 天数------------------------------------------------------------------
daysLeft = ((today.getTime() - startday.getTime()) / PerDay);
daysLeft = (daysLeft - 0.5);
daysRound = Math.round(daysLeft);
daysRemain = daysRound;
if (daysRemain == 1) day_rem = " 天 "
else day_rem = " 天 "
if (hoursRemain == 1) hour_rem = " 小时 "
else hour_rem = " 小时 "
if (minRemain == 1) min_rem = " 分钟 "
else min_rem = " 分钟 "
if (secsRemain == 1) sec_rem = " 秒"
else sec_rem = " 秒"
//---------完整的显示语句---------------------------------------------------------------------------------
timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain + min_rem + secsRemain +sec_rem;
document.up.face.value = timeRemain;//给文本框传递数值
timerID = setTimeout("showtime1()",1000);
timerRunning = true;
}
// End -->
</script>
<!----------------------------------------------------------------->
<!-- 用于计算的脚本代码结束 -->
<!----------------------------------------------------------------->
<!--------------------- 显示计算结果 ------------------------------------------------------------------>
<form name="down" onSubmit="0">
<script Language="JavaScript">
document.write("今年你已经 "+yourage+" 岁了, 你离 "+age2+" 岁还有:");
</script>
<br>
<input type="text" name="face" size="47" value="您下一岁生日的倒计时">
</form>
<p>
<br>
<form name="up" onSubmit="1">
以下是您在这世上存活的时间<br>
<input type="text" name="face" size="47" value="您在这世上存活的时间">
</form>
<!----------------------------------------------------------------------------------------------------->
<html:link page="/datetime/inputDateTime.jsp">返回上一页</html:link>
</center>
</body>
</html>
|