Ⅰ 急需日历记事本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>