Ⅰ 急需日歷記事本java源代碼
import java.util.Calendar;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.Hashtable;
public class CalendarPad extends JFrame implements MouseListener
{
int year,month,day;
Hashtable hashtable;
File file;
JTextField showDay[];
JLabel title[];
Calendar 日歷;
int 星期幾;
NotePad notepad=null;
Month 負責改變月;
Year 負責改變年;
String 星期[]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
JPanel leftPanel,rightPanel;
public CalendarPad(int year,int month,int day)
{
leftPanel=new JPanel();
JPanel leftCenter=new JPanel();
JPanel leftNorth=new JPanel();
leftCenter.setLayout(new GridLayout(7,7));
rightPanel=new JPanel();
this.year=year;
this.month=month;
this.day=day;
負責改變年=new Year(this);
負責改變年.setYear(year);
負責改變月=new Month(this);
負責改變月.setMonth(month);
title=new JLabel[7];
showDay=new JTextField[42];
for(int j=0;j<7;j++)
{
title[j]=new JLabel();
title[j].setText(星期[j]);
title[j].setBorder(BorderFactory.createRaisedBevelBorder());
leftCenter.add(title[j]);
}
title[0].setForeground(Color.red);
title[6].setForeground(Color.blue);
for(int i=0;i<42;i++)
{
showDay[i]=new JTextField();
showDay[i].addMouseListener(this);
showDay[i].setEditable(false);
leftCenter.add(showDay[i]);
}
日歷=Calendar.getInstance();
Box box=Box.createHorizontalBox();
box.add(負責改變年);
box.add(負責改變月);
leftNorth.add(box);
leftPanel.setLayout(new BorderLayout());
leftPanel.add(leftNorth,BorderLayout.NORTH);
leftPanel.add(leftCenter,BorderLayout.CENTER);
leftPanel.add(new Label("請在年份輸入框輸入所查年份(負數表示公元前),並回車確定"),
BorderLayout.SOUTH) ;
leftPanel.validate();
Container con=getContentPane();
JSplitPane split=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
leftPanel,rightPanel);
con.add(split,BorderLayout.CENTER);
con.validate();
hashtable=new Hashtable();
file=new File("日歷記事本.txt");
if(!file.exists())
{
try{
FileOutputStream out=new FileOutputStream(file);
ObjectOutputStream objectOut=new ObjectOutputStream(out);
objectOut.writeObject(hashtable);
objectOut.close();
out.close();
}
catch(IOException e)
{
}
}
notepad=new NotePad(this);
rightPanel.add(notepad);
設置日歷牌(year,month);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
setVisible(true);
setBounds(100,50,524,285);
validate();
}
public void 設置日歷牌(int year,int month)
{
日歷.set(year,month-1,1);
星期幾=日歷.get(Calendar.DAY_OF_WEEK)-1;
if(month==1||month==2||month==3||month==5||month==7
||month==8||month==10||month==12)
{
排列號碼(星期幾,31);
}
else if(month==4||month==6||month==9||month==11)
{
排列號碼(星期幾,30);
}
else if(month==2)
{
if((year%4==0&&year%100!=0)||(year%400==0))
{
排列號碼(星期幾,29);
}
else
{
排列號碼(星期幾,28);
}
}
}
public void 排列號碼(int 星期幾,int 月天數)
{
for(int i=星期幾,n=1;i<星期幾+月天數;i++)
{
showDay[i].setText(""+n);
if(n==day)
{
showDay[i].setForeground(Color.green);
showDay[i].setFont(new Font("TimesRoman",Font.BOLD,20));
}
else
{
showDay[i].setFont(new Font("TimesRoman",Font.BOLD,12));
showDay[i].setForeground(Color.black);
}
if(i%7==6)
{
showDay[i].setForeground(Color.blue);
}
if(i%7==0)
{
showDay[i].setForeground(Color.red);
}
n++;
}
for(int i=0;i<星期幾;i++)
{
showDay[i].setText("");
}
for(int i=星期幾+月天數;i<42;i++)
{
showDay[i].setText("");
}
}
public int getYear()
{
return year;
}
public void setYear(int y)
{
year=y;
notepad.setYear(year);
}
public int getMonth()
{
return month;
}
public void setMonth(int m)
{
month=m;
notepad.setMonth(month);
}
public int getDay()
{
return day;
}
public void setDay(int d)
{
day=d;
notepad.setDay(day);
}
public Hashtable getHashtable()
{
return hashtable;
}
public File getFile()
{
return file;
}
public void mousePressed(MouseEvent e)
{
JTextField source=(JTextField)e.getSource();
try{
day=Integer.parseInt(source.getText());
notepad.setDay(day);
notepad.設置信息條(year,month,day);
notepad.設置文本區(null);
notepad.獲取日誌內容(year,month,day);
}
catch(Exception ee)
{
}
}
public void mouseClicked(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
public static void main(String args[])
{
Calendar calendar=Calendar.getInstance();
int y=calendar.get(Calendar.YEAR);
int m=calendar.get(Calendar.MONTH)+1;
int d=calendar.get(Calendar.DAY_OF_MONTH);
new CalendarPad(y,m,d);
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Month extends Box implements ActionListener
{
int month;
JTextField showMonth=null;
JButton 下月,上月;
CalendarPad 日歷;
public Month(CalendarPad 日歷)
{
super(BoxLayout.X_AXIS);
this.日歷=日歷;
showMonth=new JTextField(2);
month=日歷.getMonth();
showMonth.setEditable(false);
showMonth.setForeground(Color.blue);
showMonth.setFont(new Font("TimesRomn",Font.BOLD,16));
下月=new JButton("下月");
上月=new JButton("上月");
add(上月);
add(showMonth);
add(下月);
上月.addActionListener(this);
下月.addActionListener(this);
showMonth.setText(""+month);
}
public void setMonth(int month)
{
if(month<=12&&month>=1)
{
this.month=month;
}
else
{
this.month=1;
}
showMonth.setText(""+month);
}
public int getMonth()
{
return month;
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==上月)
{
if(month>=2)
{
month=month-1;
日歷.setMonth(month);
日歷.設置日歷牌(日歷.getYear(),month);
}
else if(month==1)
{
month=12;
日歷.setMonth(month);
日歷.設置日歷牌(日歷.getYear(),month);
}
showMonth.setText(""+month);
}
else if(e.getSource()==下月)
{
if(month<12)
{
month=month+1;
日歷.setMonth(month);
日歷.設置日歷牌(日歷.getYear(),month);
}
else if(month==12)
{
month=1;
日歷.setMonth(month);
日歷.設置日歷牌(日歷.getYear(),month);
}
showMonth.setText(""+month);
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
public class NotePad extends JPanel implements ActionListener
{
JTextArea text;
JButton 保存日誌,刪除日誌;
Hashtable table;
JLabel 信息條;
int year,month,day;
File file;
CalendarPad calendar;
public NotePad(CalendarPad calendar)
{
this.calendar=calendar;
year=calendar.getYear();
month=calendar.getMonth();
day=calendar.getDay();;
table=calendar.getHashtable();
file=calendar.getFile();
信息條=new JLabel(""+year+"年"+month+"月"+day+"日",JLabel.CENTER);
信息條.setFont(new Font("TimesRoman",Font.BOLD,16));
信息條.setForeground(Color.blue);
text=new JTextArea(10,10);
保存日誌=new JButton("保存日誌") ;
刪除日誌=new JButton("刪除日誌") ;
保存日誌.addActionListener(this);
刪除日誌.addActionListener(this);
setLayout(new BorderLayout());
JPanel pSouth=new JPanel();
add(信息條,BorderLayout.NORTH);
pSouth.add(保存日誌);
pSouth.add(刪除日誌);
add(pSouth,BorderLayout.SOUTH);
add(new JScrollPane(text),BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==保存日誌)
{
保存日誌(year,month,day);
}
else if(e.getSource()==刪除日誌)
{
刪除日誌(year,month,day);
}
}
public void setYear(int year)
{
this.year=year;
}
public int getYear()
{
return year;
}
public void setMonth(int month)
{
this.month=month;
}
public int getMonth()
{
return month;
}
public void setDay(int day)
{
this.day=day;
}
public int getDay()
{
return day;
}
public void 設置信息條(int year,int month,int day)
{
信息條.setText(""+year+"年"+month+"月"+day+"日");
}
public void 設置文本區(String s)
{
text.setText(s);
}
public void 獲取日誌內容(int year,int month,int day)
{
String key=""+year+""+month+""+day;
try
{
FileInputStream inOne=new FileInputStream(file);
ObjectInputStream inTwo=new ObjectInputStream(inOne);
table=(Hashtable)inTwo.readObject();
inOne.close();
inTwo.close();
}
catch(Exception ee)
{
}
if(table.containsKey(key))
{
String m=""+year+"年"+month+"月"+day+"這一天有日誌記載,想看嗎?";
int ok=JOptionPane.showConfirmDialog(this,m,"詢問",JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if(ok==JOptionPane.YES_OPTION)
{
text.setText((String)table.get(key));
}
else
{
text.setText("");
}
}
else
{
text.setText("無記錄");
}
}
public void 保存日誌(int year,int month,int day)
{
String 日誌內容=text.getText();
String key=""+year+""+month+""+day;
String m=""+year+"年"+month+"月"+day+"保存日誌嗎?";
int ok=JOptionPane.showConfirmDialog(this,m,"詢問",JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if(ok==JOptionPane.YES_OPTION)
{
try
{
FileInputStream inOne=new FileInputStream(file);
ObjectInputStream inTwo=new ObjectInputStream(inOne);
table=(Hashtable)inTwo.readObject();
inOne.close();
inTwo.close();
table.put(key,日誌內容);
FileOutputStream out=new FileOutputStream(file);
ObjectOutputStream objectOut=new ObjectOutputStream(out);
objectOut.writeObject(table);
objectOut.close();
out.close();
}
catch(Exception ee)
{
}
}
}
public void 刪除日誌(int year,int month,int day)
{
String key=""+year+""+month+""+day;
if(table.containsKey(key))
{
String m="刪除"+year+"年"+month+"月"+day+"日的日誌嗎?";
int ok=JOptionPane.showConfirmDialog(this,m,"詢問",JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if(ok==JOptionPane.YES_OPTION)
{
try
{
FileInputStream inOne=new FileInputStream(file);
ObjectInputStream inTwo=new ObjectInputStream(inOne);
table=(Hashtable)inTwo.readObject();
inOne.close();
inTwo.close();
table.remove(key);
FileOutputStream out=new FileOutputStream(file);
ObjectOutputStream objectOut=new ObjectOutputStream(out);
objectOut.writeObject(table);
objectOut.close();
out.close();
text.setText(null);
}
catch(Exception ee)
{
}
}
}
else
{
String m=""+year+"年"+month+"月"+day+"無日誌記錄";
JOptionPane.showMessageDialog(this,m,"提示",JOptionPane.WARNING_MESSAGE);
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Year extends Box implements ActionListener
{
int year;
JTextField showYear=null;
JButton 明年,去年;
CalendarPad 日歷;
public Year(CalendarPad 日歷)
{
super(BoxLayout.X_AXIS);
showYear=new JTextField(4);
showYear.setForeground(Color.blue);
showYear.setFont(new Font("TimesRomn",Font.BOLD,14));
this.日歷=日歷;
year=日歷.getYear();
明年=new JButton("下年");
去年=new JButton("上年");
add(去年);
add(showYear);
add(明年);
showYear.addActionListener(this);
去年.addActionListener(this);
明年.addActionListener(this);
}
public void setYear(int year)
{
this.year=year;
showYear.setText(""+year);
}
public int getYear()
{
return year;
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==去年)
{
year=year-1;
showYear.setText(""+year);
日歷.setYear(year);
日歷.設置日歷牌(year,日歷.getMonth());
}
else if(e.getSource()==明年)
{
year=year+1;
showYear.setText(""+year);
日歷.setYear(year);
日歷.設置日歷牌(year,日歷.getMonth());
}
else if(e.getSource()==showYear)
{
try
{
year=Integer.parseInt(showYear.getText());
showYear.setText(""+year);
日歷.setYear(year);
日歷.設置日歷牌(year,日歷.getMonth());
}
catch(NumberFormatException ee)
{
showYear.setText(""+year);
日歷.setYear(year);
日歷.設置日歷牌(year,日歷.getMonth());
}
}
}
}
希望能幫到你,以上分為4個類。。分割線以標注了
Ⅱ 高分!!有沒有相關的工作日歷源碼,js或java,可以自己定製工作日與休息日~~謝!
<SCRIPT LANGUAGE="JavaScript" >
function runClock() {
var today = new Date();
var display= today.toLocaleString();
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=display
setTimeout("runClock()",1000)
}
<%
String userGuid = "";
if(session.getAttribute("userGUID1")!=null){
userGuid = session.getAttribute("userGUID1").toString();
}
int check = 0;
check = new DayRemindCheck().getCheck(userGuid);
if(check>0){
%>
window.open("dayRemind.jsp","每日提醒","toolbar =no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no,width=500,height=300");
<%}%>
<!-- Begin
var now = new Date();
var month_array = new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");
document.write("<form name=date_list><table bgcolor=silver width=250 ><tr><td width=250>");
document.write("<select name=month onchange=change_month(this.options.selectedIndex)>");
for(i=0;i<month_array.length;i++)
{
if (now.getMonth() != i)
{document.write ("<option value="+i+">"+month_array[i]);}
else
{document.write ("<option value="+i+" selected>"+month_array[i]);}
}
document.write("</select>");
document.write("</td><td>");
document.write ("<select name=year onchange=change_year(this.options[this.options.selectedIndex])>");
for(i=1950;i<3000;i++)
{
if (now.getYear() != i)
{document.write("<option value="+i+">"+i);}
else
{document.write("<option value="+i+" selected>"+i);}
}
document.write("</select></td></tr><tr><td colspan=2><center>");
document.write("<table bgcolor=white border=0 cellspacing = 0 cellpading = 0 width=252 ><tr bgcolor=gray align=center >");
document.write("<td ><font color=silver>一</font></td><td><font color=silver>二</td><td><font color=silver>三</td><td><font color=silver>四</td><td><font color=silver>五</td><td ><font color=silver>六</td><td ><font color=silver>日</td>");
document.write("</tr><tr>");
for(j=0;j<6;j++)
{
for(i=0;i<7;i++)
{
document.write("<td align=center id=d"+i+"r"+j+" style='cursor:hand; height=10px' onclick=getDate()></td>")
}
document.write("</tr>");
}
document.write("</table>");
document.write("</center></from></td></tr></table>");
var show_date = new Date();
function set_cal(show_date)
{
begin_day = new Date (show_date.getYear(),show_date.getMonth(),1);
begin_day_date = begin_day.getDay();
end_day = new Date (show_date.getYear(),show_date.getMonth()+1,1);
count_day = (end_day - begin_day)/1000/60/60/24;
input_table(begin_day_date,count_day);
}
set_cal(show_date);
function input_table(begin,count)
{
init();
j=0;
if (begin!=0){i=begin-1;}else{i=6}
for (c=1;c<count+1;c++)
{
colum_name = eval("d"+i+"r"+j);
if ((now.getDate() == c)&&(show_date.getMonth() == now.getMonth())&&(show_date.getYear() == now.getYear())) {colum_name.style.backgroundColor = "blue";colum_name.style.color = "white";};
colum_name.innerText = c;
i++;
if (i==7){i=0;j++;}
}
}
function init()
{
for(j=0;j<6;j++)
{
for(i=0;i<7;i++)
{
colum_name = eval("d"+i+"r"+j);
colum_name.innerText = " ";
colum_name.style.backgroundColor ="";
colum_name.style.color ="";
}
}
}
function change_month(sel_month)
{
show_date = new Date(show_date.getYear(),sel_month,1);
set_cal(show_date);
}
function change_year(sel_year)
{
sel_year = sel_year.value;
show_date = new Date(sel_year,show_date.getMonth(),1);
set_cal(show_date);
}
// End -->
</script>
Ⅲ 求 網頁日歷代碼
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>日歷代碼</title>
</head>
<body>
<SCRIPT language=JavaScript>
<!--
var lunarInfo=new Array(
0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,
0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,
0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,
0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,
0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,
0x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0,
0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,
0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x195a6,
0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,
0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,
0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,
0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,
0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,
0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,
0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0)
var solarMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var Gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");
var Zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
var Animals=new Array("鼠","牛","虎","兔","龍","蛇","馬","羊","猴","雞","狗","豬");
var solarTerm = new Array("小寒","大寒","立春","雨水","驚蟄","春分","清明","穀雨","立夏","小滿","芒種","夏至","小暑","大暑","立秋","處暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至")
var sTermInfo = new Array(0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758)
var nStr1 = new Array('日','一','二','三','四','五','六','七','八','九','十')
var nStr2 = new Array('初','十','廿','卅',' ')
var monthName = new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
//國歷節日 *表示放假日
var sFtv = new Array(
"0101*元旦",
"0214 情人節",
"0303 我生日",
"0308 婦女節",
"0312 植樹節",
"0315 消費者權益日",
"0317 St. Patrick's",
"0401 愚人節",
"0501 勞動節",
"0504 青年節",
"0512 護士節",
"0512 茵生日",
"0601 兒童節",
"0614 Flag Day",
"0701 建黨節 香港回歸紀念",
"0703 炎黃在線誕辰",
"0718 托普誕辰",
"0801 建軍節",
"0808 父親節",
"0909 毛澤東逝世紀念",
"0910 教師節",
"0928 孔子誕辰",
"1001*國慶節",
"1006 老人節",
"1024 聯合國日",
"1111 Veteran's / Remembrance Day",
"1112 孫中山誕辰紀念",
"1220 澳門回歸紀念",
"1225 Christmas Day",
"1226 毛澤東誕辰紀念")
//農歷節日 *表示放假日
var lFtv = new Array(
"0101*春節",
"0115 元宵節",
"0505 端午節",
"0707 七夕情人節",
"0715 中元節",
"0815 中秋節",
"0909 重陽節",
"1208 臘八節",
"1224 小年",
"0100*除夕")
//某月的第幾個星期幾
var wFtv = new Array(
"0131 Martin Luther King Day",
"0231 President's Day",
"0520 母親節",
"0530 Armed Forces Day",
"0531 Victoria Day",
"0716 合作節",
"0730 被奴役國家周",
"0811 Civic Holiday",
"0911 Labor Holiday",
"1021 Columbus Day",
"1144 Thanksgiving")
/*****************************************************************************
日期計算
*****************************************************************************/
//====================================== 傳回農歷 y年的總天數
function lYearDays(y) {
var i, sum = 348
for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i)? 1: 0
return(sum+leapDays(y))
}
//====================================== 傳回農歷 y年閏月的天數
function leapDays(y) {
if(leapMonth(y)) return((lunarInfo[y-1900] & 0x10000)? 30: 29)
else return(0)
}
//====================================== 傳回農歷 y年閏哪個月 1-12 , 沒閏傳回 0
function leapMonth(y) {
return(lunarInfo[y-1900] & 0xf)
}
//====================================== 傳回農歷 y年m月的總天數
function monthDays(y,m) {
return( (lunarInfo[y-1900] & (0x10000>>m))? 30: 29 )
}
//====================================== 算出農歷, 傳入日期物件, 傳回農歷日期物件
// 該物件屬性有 .year .month .day .isLeap .yearCyl .dayCyl .monCyl
function Lunar(objDate) {
var i, leap=0, temp=0
var baseDate = new Date(1900,0,31)
var offset = (objDate - baseDate)/86400000
this.dayCyl = offset + 40
this.monCyl = 14
for(i=1900; i<2050 && offset>0; i++) {
temp = lYearDays(i)
offset -= temp
this.monCyl += 12
}
if(offset<0) {
offset += temp;
i--;
this.monCyl -= 12
}
this.year = i
this.yearCyl = i-1864
leap = leapMonth(i) //閏哪個月
this.isLeap = false
for(i=1; i<13 && offset>0; i++) {
//閏月
if(leap>0 && i==(leap+1) && this.isLeap==false)
{ --i; this.isLeap = true; temp = leapDays(this.year); }
else
{ temp = monthDays(this.year, i); }
//解除閏月
if(this.isLeap==true && i==(leap+1)) this.isLeap = false
offset -= temp
if(this.isLeap == false) this.monCyl ++
}
if(offset==0 && leap>0 && i==leap+1)
if(this.isLeap)
{ this.isLeap = false; }
else
{ this.isLeap = true; --i; --this.monCyl;}
if(offset<0){ offset += temp; --i; --this.monCyl; }
this.month = i
this.day = offset + 1
}
//==============================傳回國歷 y年某m+1月的天數
function solarDays(y,m) {
if(m==1)
return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28)
else
return(solarMonth[m])
}
//============================== 傳入 offset 傳回干支, 0=甲子
function cyclical(num) {
return(Gan[num%10]+Zhi[num%12])
}
//============================== 月歷屬性
function calElement(sYear,sMonth,sDay,week,lYear,lMonth,lDay,isLeap,cYear,cMonth,cDay) {
this.isToday = false;
//國歷
this.sYear = sYear;
this.sMonth = sMonth;
this.sDay = sDay;
this.week = week;
//農歷
this.lYear = lYear;
this.lMonth = lMonth;
this.lDay = lDay;
this.isLeap = isLeap;
//干支
this.cYear = cYear;
this.cMonth = cMonth;
this.cDay = cDay;
this.color = '';
this.lunarFestival = ''; //農歷節日
this.solarFestival = ''; //國歷節日
this.solarTerms = ''; //節氣
}
//===== 某年的第n個節氣為幾日(從0小寒起算)
function sTerm(y,n) {
var offDate = new Date( ( 31556925974.7*(y-1900) + sTermInfo[n]*60000 ) + Date.UTC(1900,0,6,2,5) )
return(offDate.getUTCDate())
}
//============================== 傳回月歷物件 (y年,m+1月)
function calendar(y,m) {
var sDObj, lDObj, lY, lM, lD=1, lL, lX=0, tmp1, tmp2
var lDPOS = new Array(3)
var n = 0
var firstLM = 0
sDObj = new Date(y,m,1) //當月一日日期
this.length = solarDays(y,m) //國歷當月天數
this.firstWeek = sDObj.getDay() //國歷當月1日星期幾
for(var i=0;i<this.length;i++) {
if(lD>lX) {
sDObj = new Date(y,m,i+1) //當月一日日期
lDObj = new Lunar(sDObj) //農歷
lY = lDObj.year //農歷年
lM = lDObj.month //農歷月
lD = lDObj.day //農歷日
lL = lDObj.isLeap //農歷是否閏月
lX = lL? leapDays(lY): monthDays(lY,lM) //農歷當月最後一天
if(n==0) firstLM = lM
lDPOS[n++] = i-lD+1
}
//sYear,sMonth,sDay,week,
//lYear,lMonth,lDay,isLeap,
//cYear,cMonth,cDay
this[i] = new calElement(y, m+1, i+1, nStr1[(i+this.firstWeek)%7],
lY, lM, lD++, lL,
cyclical(lDObj.yearCyl) ,cyclical(lDObj.monCyl), cyclical(lDObj.dayCyl++) )
if((i+this.firstWeek)%7==0) this[i].color = 'red' //周日顏色
if((i+this.firstWeek)%14==13) this[i].color = 'red' //周休二日顏色
}
//節氣
tmp1=sTerm(y,m*2 )-1
tmp2=sTerm(y,m*2+1)-1
this[tmp1].solarTerms = solarTerm[m*2]
this[tmp2].solarTerms = solarTerm[m*2+1]
if(m==3) this[tmp1].color = 'red' //清明顏色
//國歷節日
for(i in sFtv)
if(sFtv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/))
if(Number(RegExp.$1)==(m+1)) {
this[Number(RegExp.$2)-1].solarFestival += RegExp.$4 + ' '
if(RegExp.$3=='*') this[Number(RegExp.$2)-1].color = 'red'
}
//月周節日
for(i in wFtv)
if(wFtv[i].match(/^(\d{2})(\d)(\d)([\s\*])(.+)$/))
if(Number(RegExp.$1)==(m+1)) {
tmp1=Number(RegExp.$2)
tmp2=Number(RegExp.$3)
this[((this.firstWeek>tmp2)?7:0) + 7*(tmp1-1) + tmp2 - this.firstWeek].solarFestival += RegExp.$5 + ' '
}
//農歷節日
for(i in lFtv)
if(lFtv[i].match(/^(\d{2})(.{2})([\s\*])(.+)$/)) {
tmp1=Number(RegExp.$1)-firstLM
if(tmp1==-11) tmp1=1
if(tmp1 >=0 && tmp1<n) {
tmp2 = lDPOS[tmp1] + Number(RegExp.$2) -1
if( tmp2 >= 0 && tmp2<this.length) {
this[tmp2].lunarFestival += RegExp.$4 + ' '
if(RegExp.$3=='*') this[tmp2].color = 'red'
}
}
}
//黑色星期五
if((this.firstWeek+12)%7==5)
this[12].solarFestival += '黑色星期五 '
//今日
if(y==tY && m==tM) this[tD-1].isToday = true;
}
//====================== 中文日期
function cDay(d){
var s;
switch (d) {
case 10:
s = '初十'; break;
case 20:
s = '二十'; break;
break;
case 30:
s = '三十'; break;
break;
default :
s = nStr2[Math.floor(d/10)];
s += nStr1[d%10];
}
return(s);
}
///////////////////////////////////////////////////////////////////////////////
var cld;
function drawCld(SY,SM) {
var i,sD,s,size;
cld = new calendar(SY,SM);
if(SY>1874 && SY<1909) yDisplay = '光緒' + (((SY-1874)==1)?'元':SY-1874)
if(SY>1908 && SY<1912) yDisplay = '宣統' + (((SY-1908)==1)?'元':SY-1908)
if(SY>1911 && SY<1950) yDisplay = '民國' + (((SY-1911)==1)?'元':SY-1911)
// if(SY>1949) yDisplay = '共和國' + (((SY-1949)==1)?'元':SY-1949)
// GZ.innerHTML = yDisplay +'年 農歷' + cyclical(SY-1900+36) + '年 【'+Animals[(SY-4)%12]+'】';
if(SY>1949) yDisplay = ''
GZ.innerHTML = yDisplay +' 農歷' + cyclical(SY-1900+36) + '年 【'+Animals[(SY-4)%12]+'】';
YMBG.innerHTML = "" + SY + "<BR>" + monthName[SM];
for(i=0;i<42;i++) {
sObj=eval('SD'+ i);
lObj=eval('LD'+ i);
sObj.className = '';
sD = i - cld.firstWeek;
if(sD>-1 && sD<cld.length) { //日期內
sObj.innerHTML = sD+1;
if(cld[sD].isToday) sObj.className = 'todyaColor'; //今日顏色
sObj.style.color = cld[sD].color; //國定假日顏色
if(cld[sD].lDay==1) //顯示農歷月
lObj.innerHTML = '<b>'+(cld[sD].isLeap?'閏':'') + cld[sD].lMonth + '月' + (monthDays(cld[sD].lYear,cld[sD].lMonth)==29?'小':'大')+'</b>';
else //顯示農歷日
lObj.innerHTML = cDay(cld[sD].lDay);
s=cld[sD].lunarFestival;
if(s.length>0) { //農歷節日
if(s.length>6) s = s.substr(0, 4)+'…';
s = s.fontcolor('red');
}
else { //國歷節日
s=cld[sD].solarFestival;
if(s.length>0) {
size = (s.charCodeAt(0)>0 && s.charCodeAt(0)<128)?8:4;
if(s.length>size+2) s = s.substr(0, size)+'…';
s = s.fontcolor('blue');
}
else { //廿四節氣
s=cld[sD].solarTerms;
if(s.length>0) s = s.fontcolor('limegreen');
}
}
if(s.length>0) lObj.innerHTML = s;
}
else { //非日期
sObj.innerHTML = '';
lObj.innerHTML = '';
}
}
}
function changeLong()
{
var y,m,ly,lm,id,im,iy,yangy,yangm,deltm,miny,tt;
CLD.SY.selectedIndex=CLD.D1.selectedIndex;
CLD.SM.selectedIndex=CLD.D2.selectedIndex;
yangm=0;yangy=0;
tt=true;
while (tt)
{
yangm=0;yangy=0;
changeCld();
for(i=0;i<42;i++)
{
sD = i - cld.firstWeek;
if(sD>-1 && sD<cld.length)
{ //日期內
if ((cld[sD].lMonth==CLD.D2.selectedIndex+1)&&(cld[sD].lYear==CLD.D1.selectedIndex+1900))
{
yangy=CLD.SY.selectedIndex+1900; yangm=CLD.SM.selectedIndex ;
tt=false;
break;
}
}
}
if (!tt) break;
pushBtm('MD');
changeCld();
// alert(CLD.SY.selectedIndex+" "+CLD.SM.selectedIndex);
for(i=0;i<42;i++)
{
sD = i - cld.firstWeek;
if(sD>-1 && sD<cld.length)
{ //日期內
if ((cld[sD].lMonth==CLD.D2.selectedIndex+1)&&(cld[sD].lYear==CLD.D1.selectedIndex+1900))
{
yangy=CLD.SY.selectedIndex+1900; yangm=CLD.SM.selectedIndex ;
tt=false;
break;
}
}
}
break;
}
// alert(yangy+" "+yangm);
//CLD.SY.selectedIndex=yangy;//-1900;
//pushBtm('YU');
//pushBtm('YD');
CLD.SM.selectedIndex=yangm;
pushBtm('MD');
pushBtm('MU');
}
//changeLong end
function changeCld() {
var y,m;
y=CLD.SY.selectedIndex+1900;
m=CLD.SM.selectedIndex;
drawCld(y,m);
}
function pushBtm(K) {
switch (K){
case 'YU' :
if(CLD.SY.selectedIndex>0) CLD.SY.selectedIndex--;
break;
case 'YD' :
if(CLD.SY.selectedIndex<149) CLD.SY.selectedIndex++;
break;
case 'MU' :
if(CLD.SM.selectedIndex>0) {
CLD.SM.selectedIndex--;
}
else {
CLD.SM.selectedIndex=11;
if(CLD.SY.selectedIndex>0) CLD.SY.selectedIndex--;
}
break;
case 'MD' :
if(CLD.SM.selectedIndex<11) {
CLD.SM.selectedIndex++;
}
else {
CLD.SM.selectedIndex=0;
if(CLD.SY.selectedIndex<149) CLD.SY.selectedIndex++;
}
break;
default :
CLD.SY.selectedIndex=tY-1900;
CLD.SM.selectedIndex=tM;
}
changeCld();
}
var Today = new Date();
var tY = Today.getFullYear();
var tM = Today.getMonth();
var tD = Today.getDate();
//////////////////////////////////////////////////////////////////////////////
var width = "130";
var offsetx = 2;
var offsety = 16;
var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var dStyle;
document.onmousemove = mEvn;
//顯示詳細日期資料
function mOvr(v) {
var s,festival;
var sObj=eval('SD'+ v);
var d=sObj.innerHTML-1;
//sYear,sMonth,sDay,week,
//lYear,lMonth,lDay,isLeap,
//cYear,cMonth,cDay
if(sObj.innerHTML!='') {
sObj.style.cursor = 's-resize';
if(cld[d].solarTerms == '' && cld[d].solarFestival == '' && cld[d].lunarFestival == '')
festival = '';
else
festival = '<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="#CCFFCC"><TR><TD>'+
'<FONT COLOR="#000000" STYLE="font-size:9pt;">'+cld[d].solarTerms + ' ' + cld[d].solarFestival + ' ' + cld[d].lunarFestival+'</FONT></TD>'+
'</TR></TABLE>';
s= '<TABLE WIDTH="130" BORDER=0 CELLPADDING="2" CELLSPACING=0 BGCOLOR="#000066"><TR><TD>' +
'<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN="right"><FONT COLOR="#ffffff" STYLE="font-size:9pt;">'+
cld[d].sYear+' 年 '+cld[d].sMonth+' 月 '+cld[d].sDay+' 日<br>星期'+cld[d].week+'<br>'+
'<font color="violet">農歷'+(cld[d].isLeap?'閏 ':' ')+cld[d].lMonth+' 月 '+cld[d].lDay+' 日</font><br>'+
'<font color="yellow">'+cld[d].cYear+'年 '+cld[d].cMonth+'月 '+cld[d].cDay + '日</font>'+
'</FONT></TD></TR></TABLE>'+ festival +'</TD></TR></TABLE>';
document.all["detail"].innerHTML = s;
if (snow == 0) {
dStyle.left = x+offsetx-(width/2);
dStyle.top = y+offsety;
dStyle.visibility = "visible";
snow = 1;
}
}
}
Ⅳ 求一個用c++ 編寫的有日程提醒功能的日歷的源代碼,希望大神寫代碼時候加一些注釋,工作量有點大,
我只有一個用c語言編的學籍管理系統,把裡面的一些語句修改一下就可以得到C++的程序代碼,還有一些細節通過調試也要修改一下,實現的功能大致相同,希望可以提供一些幫助.
#defineN1000
#defineM3
#include<stdio.h
#include<stdlib.h
structstudent{intnum;charname[10];
charsex[4];
intscore[M];inttotal;};voidinput(structstudentst[],intn){inti;for(i=0;i<n;i++){scanf("%d%s%s%d%d%d",&st[i].num,st[i].name,st[i].sex,&st[i].score[0],&st[i].score[1],&st[i].score[2]);
printf(" ");}for(i=0;i<n;i++){st[i].total=st[i].score[0]+st[i].score[1]+st[i].score[2];}}voidsort_sum(structstudentst[],intn){inti,j;structstudenttemp;
for(i=0;i<n-1;i++){for(j=i+1;j<n;j++){if(st[i].total<st[j].total){temp=st[i];
st[i]=st[j];
Ⅳ 點在圖片上 顯示日歷框 可以選擇日歷上的日期 來查詢對應時間資料庫的信息 這個JSP代碼怎麼寫
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page language="java" import="java.util.*" %>
<%
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
%>
<html>
<head>
<title>選擇日期</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META name="GENERATOR" content="IBM WebSphere Studio">
<style>
SELECT {FONT-SIZE: 9pt; LINE-HEIGHT: 11pt}
TEXTAREA {FONT-SIZE: 9pt; LINE-HEIGHT: 11pt}
INPUT {FONT-SIZE: 9pt; LINE-HEIGHT: 11pt}
TD {FONT-SIZE: 9pt; LINE-HEIGHT: 11pt}
.p { font-size: 12px; line-height: 18px}
.pp { font-size: 14px; line-height: 18px}
.cals{font-family: "Arial"color:#000000; font-size:10pt}
</style>
<%@page import = "java.util.StringTokenizer"%>
<%
String type = request.getParameter("type");
if (type==null) type="1";
Calendar cal = Calendar.getInstance();
String cur_date = cal.get(Calendar.YEAR) + "年" + (cal.get(Calendar.MONTH)+1)
+ "月" + cal.get(Calendar.DAY_OF_MONTH)+"日";
int cur_year = cal.get(Calendar.YEAR);
int cur_month = (cal.get(Calendar.MONTH)+1);
int cur_day = cal.get(Calendar.DAY_OF_MONTH);
String cur_date_string = String.valueOf(cur_year) + "-"
+ (cur_month<10?("0"+String.valueOf(cur_month)):String.valueOf(cur_month)) + "-"
+ (cur_day<10?("0"+String.valueOf(cur_day)):String.valueOf(cur_day));
String parmInitDate = request.getParameter("initdate");
int parm_year=0;
int parm_month=0;
int parm_day=0;
if(parmInitDate!=null){
StringTokenizer mytoken = null;
try{
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd");
java.util.Date date = null;
date = formatter.parse(parmInitDate);
//java.util.Calendar cal = new java.util.Calendar()
cal.setTime(date);
parm_year = cal.get(Calendar.YEAR);
parm_month = cal.get(Calendar.MONTH) + 1;
parm_day = cal.get(Calendar.DAY_OF_MONTH );
}catch(Exception e){
//out.print(e);
}
}
parm_year= parm_year==0?cur_year:parm_year;
parm_month= parm_month==0?cur_month:parm_month;
parm_day= parm_day==0?cur_day:parm_day;
%>
<script LANGUAGE="vbscript">
<!--
dim cal(6,7)
dim sToday
dim sCurDate
dim sSeldate
dim selx,sely
sCurdate="<%=cur_date_string%>"
sSeldate="<%=parm_year+"-"+parm_month+"-"+parm_day%>"
sub getDate()
if window.event.srcElement.innerText = "" or window.event.srcElement.innerText = " " then exit sub
for i = 1 to 6
for j = 1 to 7
if cal(i,j).bgcolor="#0000ff" then
cal(i,j).bgcolor=""
cal(i,j).style.color="black"
end if
next
next
if window.event.srcElement.bgcolor<>"#ffff00" then
window.event.srcElement.bgcolor="blue"
window.event.srcElement.style.color="white"
end if
aa = window.year.value & "-" & right(window.month.value+100,2) & "-" & right(window.event.srcelement.innertext+100,2)
window.sel_date.innerText=aa
end sub
sub getTime()
aa=""
if window.hour.value<>"00" or window.minute.value<>"00" or window.second.value<>"00" then
aa=window.hour.value & ":" & window.minute.value & ":" & window.second.value
end if
if window.sel_date.innerText = "" then
window.sel_date.innerText = sCurDate
end if
window.sel_time.innerText=aa
end sub
sub ret ()
if window.sel_date.innerText <> "" then
window.returnValue = window.sel_date.innerText
if window.sel_time.innerText="" then
window.sel_time.innerText=window.hour.value & ":" & window.minute.value & ":" & window.second.value
end if
if window.sel_time.innerText <>"" then
window.returnValue = window.sel_date.innerText & " " & window.sel_time.innerText
end if
end if
window.event.returnValue = false
set cal(6,7) = nothing
window.close()
end sub
sub cancel ()
window.returnValue = ""
window.event.returnValue = false
set cal(6,7) = nothing
window.close()
end sub
sub draw
dim yy,mm,dd,thisday,lastmm,maxday
dim nextmm
yy = window.year.value
mm = window.month.value
dd = datepart("d",sSeldate)
thisday = dateserial (yy,mm,1)
set cal(1,1) = t10:set cal(1,2) = t11:set cal(1,3) = t12:set cal(1,4) = t13:set cal(1,5) = t14:set cal(1,6) = t15:set cal(1,7) = t16
set cal(2,1) = t20:set cal(2,2) = t21:set cal(2,3) = t22:set cal(2,4) = t23:set cal(2,5) = t24:set cal(2,6) = t25:set cal(2,7) = t26
set cal(3,1) = t30:set cal(3,2) = t31:set cal(3,3) = t32:set cal(3,4) = t33:set cal(3,5) = t34:set cal(3,6) = t35:set cal(3,7) = t36
set cal(4,1) = t40:set cal(4,2) = t41:set cal(4,3) = t42:set cal(4,4) = t43:set cal(4,5) = t44:set cal(4,6) = t45:set cal(4,7) = t46
set cal(5,1) = t50:set cal(5,2) = t51:set cal(5,3) = t52:set cal(5,4) = t53:set cal(5,5) = t54:set cal(5,6) = t55:set cal(5,7) = t56
set cal(6,1) = t60:set cal(6,2) = t61:set cal(6,3) = t62:set cal(6,4) = t63:set cal(6,5) = t64:set cal(6,6) = t65:set cal(6,7) = t66
for i = 1 to 6
for j = 1 to 7
cal(i,j).innertext = " "
cal(i,j).style.cursor = ""
cal(i,j).bgcolor=""
next
next
// cal(1,cint(datepart("w",thisday))).innertext = 1
// cal(1,cint(datepart("w",thisday))).style.cursor="hand"
//計算選擇預設日期
lastmm = datepart("m",thisday)
nextmm = lastmm + 1
if nextmm= 13 then nextmm = 1
maxday = datepart("d",dateadd("d",-1,dateserial (yy,nextmm,"1") ) )
if dd>maxday then dd = maxday
//預設
i = 1 'the line
do until (datepart("m",thisday) - lastmm <>0)
if datepart ("w",thisday) = 1 then i = i + 1
cal(i,cint(datepart("w",thisday))).innertext = datepart("d",thisday)
if thisday=date then
cal(i,cint(datepart("w",thisday))).bgcolor="#A7A4D9" 'tt1
cal(i,cint(datepart("w",thisday))).style.color="red"
else
cal(i,cint(datepart("w",thisday))).style.color="black"
end if
if(datepart("d",thisday)=dd) then
if thisday<>date then
cal(i,cint(datepart("w",thisday))).bgcolor="blue"
cal(i,cint(datepart("w",thisday))).style.color="white"
end if
dim showday
showday = datepart("yyyy",thisday)& "-"
if(datepart("m",thisday)<10) then
showday = showday & "0"
end if
showday = showday & datepart("m",thisday)& "-"
if(datepart("d",thisday)<10) then
showday = showday & "0"
end if
showday = showday & datepart("d",thisday)
window.sel_date.innerText= showday
end if
cal(i,cint(datepart("w",thisday))).style.cursor="hand"
thisday = thisday + 1
loop
for i = 1 to 6
for j = 1 to 7
cal(i,j).style.fontsize = "9pt" '" normal small-caps 8pt serif"
next
next
end sub
sub up()
for i = 1 to 6
for j = 1 to 7
if cal(i,j).bgcolor="#0000ff" then
cal(i,j).bgcolor=""
cal(i,j).style.color="black"
end if
next
next
if window.month.value = 12 then
if window.year.value < 2100 then window.year.value = window.year.value + 1
window.month.value = 1
else
window.month.value = window.month.value + 1
end if
draw()
end sub
sub down ()
for i = 1 to 6
for j = 1 to 7
if cal(i,j).bgcolor="#0000ff" then
cal(i,j).bgcolor=""
cal(i,j).style.color="black"
end if
next
next
if window.month.value = 1 then
if window.year.value > 1996 then window.year.value = window.year.value - 1
window.month.value = 12
else
window.month.value = window.month.value - 1
end if
draw()
end sub
-->
</script>
<script ID="clientEventHandlersVBS" LANGUAGE="vbscript">
<!--
Sub year_onchange
draw()
End Sub
Sub month_onchange
draw()
End Sub
sub init ()
aa = date()
bb = <%=parm_year%>
if bb >= 1950 and bb <= 2100 then window.year.value = bb
bb = <%=parm_month%>
window.month.value = bb
sToday=<%=parm_day%>
draw ()
end sub
-->
</script>
<script language="javascript" for="t1" event="onkeydown">
//Esc退出
var keyDown = event.keyCode
if(keyDown==27){
window.close()
}
</script>
</head>
<body onload="init" leftmargin="12" topmargin="7" >
<center>
<!--<font class='pp'>今天是<%=cur_date%></font><br> -->
<table border="0" width="200" cellspacing="0" cellpadding="1" bgcolor="snow" id="t1" align="center">
<tr>
<td colspan='7' nowrap >
<select id="year" name="year">
<%for (int i=2000; i<=2020; i++) {%>
<option value=<%=i%>><%=i%></option>
<%}%>
</select>
<select id="month" name="month">
<%for (int i=1; i<=12; i++) {%>
<option value=<%=i%>><%=i%>月</option>
<%}%>
</select>
<img src="../images/arr04.gif" id="up" language="vbscript" style='cursor:hand' onclick="down()" accesskey=1 align="absmiddle">
<img src="../images/arr05.gif" id="down" language="vbscript" style='cursor:hand' onclick="up()" accesskey=2 align="absmiddle">
</td>
</tr>
<tr>
<td colspan='7' height="5" > </td>
</tr>
<tr bgcolor="#7975C6">
<td align='center' class="cals" height="23" align="absmiddle">日</td>
<td align='center' class="cals" align="absmiddle">一</td>
<td align='center' class="cals" align="absmiddle">二</td>
<td align='center' class="cals" align="absmiddle">三</td>
<td align='center' class="cals" align="absmiddle">四</td>
<td align='center' class="cals" align="absmiddle">五</td>
<td align='center' class="cals" align="absmiddle">六</td>
</tr>
<%for (int i=1; i<=6; i++) {%>
<tr bgcolor="#e6e6fa">
<%for (int j=0; j<=6; j++) {%>
<td align='center' id=t<%=i%><%=j%> onclick="getDate()" ondblclick="ret()" class="cals"></td>
<%}%>
</tr>
<%}%>
<%String disp=null;%>
<%if (type.compareTo("2")==0) {%>
<tr>
<td colspan='7' nowrap height="28" align="center" valign="bottom" >
<select id="hour" name="hour" onchange='getTime()'>
<%
for (int i=0; i<=23; i++) {
disp=String.valueOf(i);
if (disp.length()==1) disp = "0"+disp;
%>
<option value=<%=disp%><%if (i==0) out.print(" selected");%>><%=disp%></option>
<%}%>
</select><font class='p'>時</font>
<select id="minute" name="minute" onchange='getTime()'>
<%
for (int i=0; i<=59; i++) {
disp=String.valueOf(i);
if (disp.length()==1) disp = "0"+disp;
%>
<option value=<%=disp%><%if (i==0) out.print(" selected");%>><%=disp%></option>
<%}%>
</select><font class='p'>分</font>
<select id="second" name="second" onchange='getTime()'>
<%
for (int i=0; i<=59; i++) {
disp=String.valueOf(i);
if (disp.length()==1) disp = "0"+disp;
%>
<option value=<%=disp%><%if (i==0) out.print(" selected");%>><%=disp%></option>
<%}%>
</select><font class='p'>秒</font>
</td></tr>
<%}%>
</table>
<table border='0' width='180' style="display:none">
<tr>
<td nowrap>
時間:
<font color='red'>
<span id='sel_date' name='sel_date'></span>
<span id='sel_time' name='sel_time'></span>
</font>
</td>
</tr>
</table>
<table border='0' cellspacing="0" cellpadding="0" >
<tr><td height="4"></td></tr>
<tr><td align="absmiddle"><img src="../images/bt_sure.gif" onclick='ret()'></td></tr>
</table>
</center>
<%
String initH="00";
String initM="00";
String initS="00";
if(type.equals("2")){
if(parmInitDate==null) parmInitDate="";
parmInitDate=parmInitDate.trim();
if(parmInitDate.length()>10){
initH=parmInitDate.substring(11,13);
initM=parmInitDate.substring(14,16);
initS=parmInitDate.substring(17,19);
}else{
//初始化為當前時間
java.text.SimpleDateFormat sdf=null;
String curTime="";
try{
sdf=new java.text.SimpleDateFormat("HH:mm:ss");
curTime=sdf.format(new java.util.Date());
}catch(Exception e){
curTime="00:00:00";
System.out.println("格式為日期出錯");
}
initH=curTime.substring(0,2);
initM=curTime.substring(3,5);
initS=curTime.substring(6,8);
}
}
%>
<script language="javascript">
var itype='<%=type %>';
var hh='<%=initH %>';
var mm='<%=initM %>';
var ss='<%=initS %>';
if(itype=='2'){
//初始化數據
var objh=document.getElementById('hour');
var objm=document.getElementById('minute');
var objs=document.getElementById('second');
objh.value=hh;
objm.value=mm;
objs.value=ss;
}
</script>
</body>
</html>