net显示今天农历的代码!

合集下载

农历时间日期代码

农历时间日期代码

农历时间日期<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>单行带农历的日期时间代码</title></head><body><SCRIPT language=JavaScript><!--function CalConv(){FIRSTYEAR = 1998;LASTYEAR = 2031;today = new Date();SolarYear = today.getFullYear();SolarMonth = today.getMonth() + 1;SolarDate = today.getDate();Weekday = today.getDay();LunarCal = [new tagLunarCal( 27, 5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ),new tagLunarCal( 46, 0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ), /* 88 */ new tagLunarCal( 35, 0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ), /* 89 */ new tagLunarCal( 23, 4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 42, 0, 1, 4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 31, 0, 2, 9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),new tagLunarCal( 21, 2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), /* 93 */ new tagLunarCal( 39, 0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 28, 7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ),new tagLunarCal( 48, 0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ),new tagLunarCal( 37, 0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 97 */ new tagLunarCal( 25, 5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),new tagLunarCal( 44, 0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),new tagLunarCal( 33, 0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 22, 4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), /* 101 */ new tagLunarCal( 40, 0, 1, 2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 30, 9, 2, 7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),new tagLunarCal( 49, 0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1 ),new tagLunarCal( 38, 0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), /* 105 */ new tagLunarCal( 27, 6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ),new tagLunarCal( 46, 0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0 ),new tagLunarCal( 35, 0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ),new tagLunarCal( 24, 4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), /* 109 */new tagLunarCal( 42, 0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 31, 0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 21, 2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),new tagLunarCal( 40, 0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), /* 113 */new tagLunarCal( 28, 6, 2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ),new tagLunarCal( 47, 0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 ),new tagLunarCal( 36, 0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ),new tagLunarCal( 25, 5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), /* 117 */new tagLunarCal( 43, 0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ),new tagLunarCal( 32, 0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0 ),new tagLunarCal( 22, 3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ) ];/* 民國年每月之日數all by */SolarCal = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];/* 民國年每月之累積日數, 平年與閏年*/SolarDays = [ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397 ];if ( SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR ) return 1;sm = SolarMonth - 1;if ( sm < 0 || sm > 11 ) return 2;leap = GetLeap( SolarYear );if ( sm == 1 )d = leap + 28;elsed = SolarCal[sm];if ( SolarDate < 1 || SolarDate > d ) return 3;y = SolarYear - FIRSTYEAR;acc = SolarDays[ leap*14 + sm ] + SolarDate;kc = acc + LunarCal[y].BaseKanChih;Kan = kc % 10;Chih = kc % 12;Age = kc % 60;if ( Age < 22 )Age = 22 - Age;elseAge = 82 - Age;if ( acc <= LunarCal[y].BaseDays ) {y--;LunarYear = SolarYear - 1;leap = GetLeap( LunarYear );sm += 12;acc = SolarDays[leap*14 + sm] + SolarDate;}elseLunarYear = SolarYear;l1 = LunarCal[y].BaseDays;for ( i=0; i<13; i++ ) {l2 = l1 + LunarCal[y].MonthDays[i] + 29;if ( acc <= l2 ) break;l1 = l2;}LunarMonth = i + 1;LunarDate = acc - l1;im = LunarCal[y].Intercalation;if ( im != 0 && LunarMonth > im ) {LunarMonth--;if ( LunarMonth == im ) LunarMonth = -im;}if ( LunarMonth > 12 ) LunarMonth -= 12;today=new Date();function initArray(){this.length=initArray.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=initArray.arguments[i] }var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); document.write("", today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日&nbsp;",d[today.getDay()+1],"");months = ["一","二","三","四","五","六","七","八","九","十","十一","十二"];days = ["初一","初二","初三","初四","初五","初六","初七","初八","初九","初十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十","廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十"];document.write( "&nbsp;农历"+months[LunarMonth-1]+"月" + days[LunarDate-1] + "");return 0;}/* 求此民國年是否為閏年, 返回0 為平年, 1 為閏年*/function GetLeap( year ){if ( year % 400 == 0 )return 1;else if ( year % 100 == 0 )return 0;else if ( year % 4 == 0 )return 1;elsereturn 0;}function tagLunarCal( d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) { this.BaseDays = d; /* 到民國1 月1 日到農曆正月初一的累積日數*/this.Intercalation = i; /* 閏月月份. 0==此年沒有閏月*/this.BaseWeekday = w; /* 此年民國1 月1 日為星期幾再減1 */this.BaseKanChih = k; /* 此年民國1 月1 日之干支序號減1 */this.MonthDays = [ m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13 ]; /* 此農曆年每月之大小, 0==小月(29日), 1==大月(30日) */}//--></SCRIPT><a target=_blank href=><FONT color=#2b68a7><SCRIPT>CalConv();</SCRIPT></FONT></a></body></html>本代码由<a href=>网页特效网</a>提供QQ菜单似的下拉门<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><title>下拉滚动门</title><style type="text/css">body{margin:10px;padding:10px;}body,td,div,span,li{font-size:12px;}.title01,.title02{color:#fff;font-weight:bold;}#DoorP{border:12px solid #eee; width:150px;height:300px;padding:4px; background:#fff;}.title01{width:100%;height:25px; background:#00ccff; cursor:pointer;}.title02{width:100%;height:25px; background:#99cc00; cursor:pointer;}.content{background:#eee;border-bottom:2px solid #fff; overflow:hidden;color:#666;padding-left:4px;padding-right:4px;line-height:18px;}</style><!--棕:#eee;蓝:#00ccff;绿:#99cc00;--></head><body><div id="DoorP"><table><tr><td>第一层信息</td></tr></table><div class="content">十三妖<br/>十三妖<br/>十三妖<br/></div><table><tr><td>第二层信息</td></tr></table><div class="content"> ThirdteenDevil</div><table><tr><td>第三层信息</td></tr></table><div class="content">devil13th</div></div><script type="text/javascript">var open = 2;// 设置初始打开的层序号var openState = new Array();var closeState = new Array();var dH = 220;function $(id){if(document.getElementById(id)) {return document.getElementById(id); }else{alert("没有找到!");}}function $tag(id,tagName){return $(id).getElementsByTagName(tagName)}function closeMe(Cid,Oid){var h = parseInt(Ds[Cid].style.height);//alert(h);if(h > 0){h = h - Math.ceil(h/3);Ds[Cid].style.height = h+"px";}else{openMe(Oid);clearTimeout(closeState[Cid]);return false;}closeState[Cid] = setTimeout("closeMe("+Cid+","+Oid+")"); }function openMe(Oid){var h = parseInt(Ds[Oid].style.height);//alert(h);if(h < dH){h = h + Math.ceil((dH-h)/3);Ds[Oid].style.height = h+"px";}else{clearTimeout(openState[Oid]);return false;}openState[Oid] = setTimeout("openMe("+Oid+")");}var Ds = $tag("DoorP","div");var Ts = $tag("DoorP","table");if(Ds.length != Ts.length){alert("标题和内容数目不相同!");}for(var i = 0 ; i < Ds.length ; i++){if(i==open){Ds[i].style.height = dH+"px";Ts[i].className="title01";}else{Ds[i].style.height = "0px";Ts[i].className="title02";}Ts[i].value = i;Ts[i].onclick = function(){if(open==this.value){return false;}Ts[open].className="title02";Ts[this.value].className="title01";for(var i = 0 ; i < openState.length ; i++){clearTimeout(openState[i]);clearTimeout(closeState[i]);}closeMe(open,this.value);//openMe(this.value);open = this.value;}}//直接打开层函数function showDiv(id){Ds[id].style.height=dH+"px";Ds[open].style.height="0px";open = id;}//渐渐打开层函数</script></body></html>本代码由<a href=>网页特效网</a>提供文字的折叠与展开<div align="center"><table border="0" width="300" cellpadding="0" style="border-collapse: collapse" id="table1" bgcolor="#F3F3F3" cellspacing="10"><tr><td valign="top" style="line-height: 150%"><div class="block" id="smallContent" style="display:block"><span style="font-size: 9pt"> <b>专辑介绍:</b>青春光影是由中国80后影像精英共同组建的新媒体影视摄制机构。

带农历的日期代码

带农历的日期代码
if ((yyyy > 1901) && (CnDateofDate(new Date((yyyy - 1)+"/12/31")) < 0)){
ResultMonth = - CnMonth[0];}
else {ResultMonth = CnMonth[0];}
ResultDay = CnBeginDay + DaysCount;
var Dizhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
return Tiangan[YYYY%10]+Dizhi[YYYY%12];
}
function CnDateofDateStr(DateGL){
if(CnMonthofDate(DateGL)=="零月") return "请调整您的计算机日期!";
0x87,0x6a,0x57,0x04,0x12,0x75,0x2b,0x00,0x1d,0xb6,0x95,0x00,0x8a,0xad,0x55,0x02,
0x15,0x55,0xaa,0x00,0x82,0x55,0x6c,0x07,0x0d,0xc9,0x76,0x00,0x17,0x64,0xb7,0x00,
CnDaysCount+= CnMonthDays[I];
I++;
}

Java万年历源代码,可显示公历、农历、系统时间、国际时间

Java万年历源代码,可显示公历、农历、系统时间、国际时间

import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.table.DefaultTableModel;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;import java.util.GregorianCalendar;import java.util.Locale;import java.util.TimeZone;public class wannianli extends JFrame implements ActionListener, MouseListener {private Calendar cld = Calendar.getInstance();//获取一个Calendar类的实例对象private String[] astr = { "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" };private DefaultTableModel dtm = new DefaultTableModel(null, astr);private JTable table = new JTable(dtm);private JScrollPane sp = new JScrollPane(table);private JButton bLastYear = new JButton("上一年");private JButton bNextYear = new JButton("下一年");private JButton bLastMonth = new JButton("上月");private JButton bNextMonth = new JButton("下月");private JPanel p1 = new JPanel(); // 设立八个中间容器,装入布局控制日期的按钮模块private JPanel p2 = new JPanel(new GridLayout(3,2));//网格布局private JPanel p3 = new JPanel(new BorderLayout());//边界布局private JPanel p4 = new JPanel(new GridLayout(2,1));private JPanel p5 = new JPanel(new BorderLayout());private JPanel p6 = new JPanel(new GridLayout(2,2));private JPanel p7 = new JPanel(new GridLayout(2,1));private JPanel p8 = new JPanel(new BorderLayout());private JComboBox timeBox = newJComboBox(TimeZone.getAvailableIDs());//对所有支持时区进行迭代,获取所有的id;private JTextField jtfYear = new JTextField(5);// jtfYeaar年份显示输入框private JTextField jtfMonth = new JTextField(2);// jtfMouth月份显示输入框private JTextField timeField=new JTextField();//各城市时间显示框private static JTextArea jta = new JTextArea(10,5);//农历显示区private JScrollPane jsp = new JScrollPane(jta);private JLabel l = new JLabel("花江小精灵:亲!你可以直接输入年月查询.");private JLabel lt = new JLabel();private JLabel ld = new JLabel();private JLabel lu = new JLabel("农历和节气");private JLabel null1=new JLabel();private int lastTime;//private String localTime = null;private String s = null;private SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy年MM月dd 日 hh时mm分ss秒");public wannianli() {super("花江日历过去仅留追忆,未来刚生憧憬,唯有坚守本心,把握今天 ZYT 詹永堂 ");// 框架命名this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 窗口关闭函数this.getContentPane().setLayout(new BorderLayout(9, 10));jta.setLineWrap(true);// 长度大于分配长度时候则换行jta.setFont(new Font("黑体", Font.BOLD, 16));table.setBackground(Color.white);table.setGridColor(Color.pink);// 星期之间的网格线是灰色的table.setBackground(Color.white);table.setColumnSelectionAllowed(true);// 将table中的列设置为可选择的table.setSelectionBackground(Color.pink);// 当选定某一天时背景颜色为黑色table.setSelectionForeground(Color.GREEN);table.setBackground(new Color(184,207, 229));// 日期显示表格为浅蓝色table.setFont(new Font("黑体", Font.BOLD, 24));// 日期数字字体格式table.setRowHeight(26);// 表格的高度table.addMouseListener(this); // 鼠标监听器、lu.setFont(new Font("黑体", Font.BOLD, 22));//农历标签格氏jtfYear.addActionListener(this);// 可输入年份的文本框// 为各个按钮添加监听函数bLastYear.addActionListener(this);bNextYear.addActionListener(this);bLastMonth.addActionListener(this);bNextMonth.addActionListener(this);timeBox.addItemListener(new TimeSelectedChangedListener());// 将按钮添加到Jpane上p1.add(bLastYear);p1.add(jtfYear);// 年份输入文本框p1.add(bNextYear);p1.add(bLastMonth);p1.add(jtfMonth);p1.add(bNextMonth);p3.add(jsp, BorderLayout.SOUTH);p3.add(lu,BorderLayout.CENTER);p3.add(ld, BorderLayout.NORTH);p4.add(lt);p4.add(l);p5.add(p4, BorderLayout.SOUTH);p5.add(sp, BorderLayout.CENTER);p5.add(p1, BorderLayout.NORTH);p6.add(timeBox);p6.add(null1);p6.add(timeField);p8.add(p2,BorderLayout.CENTER);p8.add(p7,BorderLayout.SOUTH);this.getContentPane().add(p3, BorderLayout.EAST);this.getContentPane().add(p5, BorderLayout.CENTER);this.getContentPane().add(p6,BorderLayout.SOUTH);this.getContentPane().add(p8,BorderLayout.WEST);String[] strDate = DateFormat.getDateInstance().format(new Date()) .split("-");// 获取日期cld.set(Integer.parseInt(strDate[0]), Integer.parseInt(strDate[1]) - 1,0);showCalendar(Integer.parseInt(strDate[0]),Integer.parseInt(strDate[1]), cld);jtfMonth.setEditable(false);// 设置月份文本框为不可编辑jtfYear.setText(strDate[0]);jtfMonth.setText(strDate[1]);this.showTextArea(strDate[2]);ld.setFont(new Font("新宋体", Font.BOLD, 24));new Timer(lt).start();new TimeThread().start();this.setBounds(200, 200, 700, 350);this.setResizable(false);this.setVisible(true);}public void showCalendar(int localYear, int localMonth, Calendar cld) {int Days = getDaysOfMonth(localYear, localMonth) +cld.get(Calendar.DAY_OF_WEEK) -2;Object [] ai = new Object[7];lastTime = 0;for (int i = cld.get(Calendar.DAY_OF_WEEK)-1; i <= Days; i++) {ai[i%7] =String.valueOf(i-(cld.get(Calendar.DAY_OF_WEEK)-2));if (i%7 == 6){dtm.addRow(ai);ai = new Object[7];lastTime++;}}dtm.addRow(ai);}public int getDaysOfMonth(int Year, int Month) {//计算各月的天数if(Month==1||Month==3||Month==5||Month==7||Month==8||Month==10||Mont h==12){return 31;}if(Month==4||Month==6||Month==9||Month==11){return 30;}if(Year%4==0&&Year%100!=0||Year%400==0)//闰年{return 29;}else {return 28;}}public void actionPerformed(ActionEvent e)//从界面上获取年月数据{if(e.getSource() == jtfYear || e.getSource() == bLastYear || e.getSource() == bNextYear ||e.getSource() == bLastMonth || e.getSource() == bNextMonth){int m, y;try//控制输入的年份正确,异常控制{if (jtfYear.getText().length() != 4){throw new NumberFormatException();}y = Integer.parseInt(jtfYear.getText());m = Integer.parseInt(jtfMonth.getText());}catch (NumberFormatException ex){JOptionPane.showMessageDialog(this, "请输入4位0-9的数字!", "年份有误", JOptionPane.ERROR_MESSAGE);return;}ld.setText("没有选择日期");for (int i = 0; i < lastTime+1; i++){ dtm.removeRow(0);}if(e.getSource() ==bLastYear){ jtfYear.setText(String.valueOf(--y)); }if(e.getSource() ==bNextYear){jtfYear.setText(String.valueOf(++y)); }if(e.getSource() == bLastMonth){if(m == 1){jtfYear.setText(String.valueOf(--y));m = 12;jtfMonth.setText(String.valueOf(m));}else{jtfMonth.setText(String.valueOf(--m));}}if(e.getSource() == bNextMonth){if(m == 12){jtfYear.setText(String.valueOf(++y));m = 1;jtfMonth.setText(String.valueOf(m));}else{jtfMonth.setText(String.valueOf(++m));}}cld.set(y, m-1, 0);showCalendar(y, m, cld);}}public void mouseClicked(MouseEvent e){jta.setText(null);int r = table.getSelectedRow();int c = table.getSelectedColumn();if (table.getValueAt(r,c) == null){ld.setText("没有选择日期");}else{this.showTextArea(table.getValueAt(r,c));}}private void showTextArea(Object selected){ld.setText(jtfYear.getText()+"年"+jtfMonth.getText()+"月"+selected+"日");}public static void main(String[] args){JFrame.setDefaultLookAndFeelDecorated(true);JDialog.setDefaultLookAndFeelDecorated(true);new wannianli();jta.setText(today());}private void updateTimeText(String timeZoneId) {if(timeZoneId != null){TimeZone timeZone = TimeZone.getTimeZone(timeZoneId);dateFormat.setTimeZone(timeZone);Calendar calendar = Calendar.getInstance();calendar.setTimeZone(timeZone);timeField.setText(dateFormat.format(calendar.getTime()));}else{timeField.setText(null);}}private class TimeSelectedChangedListener implements ItemListener { public void itemStateChanged(ItemEvent e) {if (e.getStateChange()==ItemEvent.SELECTED) {if (e.getItem() instanceof String) {s = e.getItem().toString();}}}}private class TimeThread extends Thread{public void run(){while(true){updateTimeText(s);try{Thread.sleep(100);}catch(InterruptedException e){e.printStackTrace();}}}}class Timer extends Thread //显示系统时间{private JLabel lt;private SimpleDateFormat fy = new SimpleDateFormat(" Gyyyy.MM.dd HH:mm:ss ");public Timer(JLabel lt){this.lt=lt;}public void run(){while(true){try{lt.setText(fy.format(new Date()));this.sleep(500);}catch(InterruptedException ex){ex.printStackTrace();}}}}final private static long[] lunarInfo= new long[] { 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 };final private static int[] year20 = new int[] { 1, 4, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };final private static int[] year19 = new int[] { 0, 3, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 };final private static int[] year2000 = new int[] { 0, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };public final static String[] nStr1 = new String[] { "", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一","十二" };private final static String[] Gan = new String[] { "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" };private final static String[] Zhi = new String[] { "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥" };private final static String[] Animals = new String[] { "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪" };// 传回农历 y年的总天数final private static int lYearDays(int y) {int i, sum = 348;for (i = 0x8000; i > 0x8; i >>= 1) {if ((lunarInfo[y - 1900] & i) != 0)sum += 1;}return (sum + leapDays(y));}// 传回农历 y年闰月的天数final private static int leapDays(int y) {if (leapMonth(y) != 0) {if ((lunarInfo[y - 1900] & 0x10000) != 0)return 30;elsereturn 29;} elsereturn 0;}// 传回农历 y年闰哪个月 1-12 , 没闰传回 0final private static int leapMonth(int y) {return (int) (lunarInfo[y - 1900] & 0xf);}//传回农历 y年m月的总天数final private static int monthDays(int y, int m) {if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0)return 29;elsereturn 30;}// 传回农历 y年的生肖final public static String AnimalsYear(int y) {return Animals[(y - 4) % 12];}//传入月日的offset 传回干支,0=甲子final private static String cyclicalm(int num) {return (Gan[num % 10] + Zhi[num % 12]);}// 传入 offset 传回干支, 0=甲子final public static String cyclical(int y) {int num = y - 1900 + 36;return (cyclicalm(num));}// 传出农历.year0 .month1 .day2 .yearCyl3 .monCyl4 .dayCyl5 .isLeap6final private long[] Lunar(int y, int m) {long[] nongDate = new long[7];int i = 0, temp = 0, leap = 0;Date baseDate = new GregorianCalendar(1900 + 1900, 1,31).getTime();Date objDate = new GregorianCalendar(y + 1900, m, 1).getTime();long offset = (objDate.getTime() - baseDate.getTime()) / 86400000L;if (y < 2000)offset += year19[m - 1];if (y > 2000)offset += year20[m - 1];if (y == 2000)offset += year2000[m - 1];nongDate[5] = offset + 40;nongDate[4] = 14;for (i = 1900; i < 2050 && offset > 0; i++) {temp = lYearDays(i);offset -= temp;nongDate[4] += 12;}if (offset < 0) {offset += temp;i--;nongDate[4] -= 12;}nongDate[0] = i;nongDate[3] = i - 1864;leap = leapMonth(i); // 闰哪个月nongDate[6] = 0;for (i = 1; i < 13 && offset > 0; i++) {// 闰月if (leap > 0 && i == (leap + 1) && nongDate[6] == 0) { --i;nongDate[6] = 1;temp = leapDays((int) nongDate[0]);} else {temp = monthDays((int) nongDate[0], i);}// 解除闰月if (nongDate[6] == 1 && i == (leap + 1))nongDate[6] = 0;offset -= temp;if (nongDate[6] == 0)nongDate[4]++;}if (offset == 0 && leap > 0 && i == leap + 1) {if (nongDate[6] == 1) {nongDate[6] = 0;} else {nongDate[6] = 1;--i;--nongDate[4];}}if (offset < 0) {offset += temp;--i;--nongDate[4];}nongDate[1] = i;nongDate[2] = offset + 1;return nongDate;}// 传出y年m月d日对应的农历.year0 .month1 .day2 .yearCyl3 .monCyl4 .dayCyl5 .isLeap6final public static long[] calElement(int y, int m, int d) {long[] nongDate = new long[7];int i = 0, temp = 0, leap = 0;Date baseDate = new GregorianCalendar(0 + 1900, 0, 31).getTime();Date objDate = new GregorianCalendar(y, m - 1, d).getTime();long offset = (objDate.getTime() - baseDate.getTime()) / 86400000L;nongDate[5] = offset + 40;nongDate[4] = 14;for (i = 1900; i < 2050 && offset > 0; i++) {temp = lYearDays(i);offset -= temp;nongDate[4] += 12;}if (offset < 0) {offset += temp;i--;nongDate[4] -= 12;}nongDate[0] = i;nongDate[3] = i - 1864;leap = leapMonth(i); // 闰哪个月nongDate[6] = 0;for (i = 1; i < 13 && offset > 0; i++) {// 闰月if (leap > 0 && i == (leap + 1) && nongDate[6] == 0) { --i;nongDate[6] = 1;temp = leapDays((int) nongDate[0]);} else {temp = monthDays((int) nongDate[0], i);}// 解除闰月if (nongDate[6] == 1 && i == (leap + 1))nongDate[6] = 0;offset -= temp;if (nongDate[6] == 0)nongDate[4]++;}if (offset == 0 && leap > 0 && i == leap + 1) { if (nongDate[6] == 1) {nongDate[6] = 0;} else {nongDate[6] = 1;--i;--nongDate[4];}}if (offset < 0) {offset += temp;--i;--nongDate[4];}nongDate[1] = i;nongDate[2] = offset + 1;return nongDate;}public final static String getChinaDate(int day) { String a = "";if (day == 10)return"初十";if (day == 20)return"二十";if (day == 30)return"三十";int two = (int) ((day) / 10);if (two == 0)a = "初";if (two == 1)a = "十";if (two == 2)a = "廿";if (two == 3)a = "三";int one = (int) (day % 10);switch (one) {case 1:a += "一";break;case 2:a += "二";break;case 3:a += "三";break;case 4:a += "四";break;case 5:a += "五";break;case 6:a += "六";break;case 7:a += "七";break;case 8:a += "八";break;case 9:a += "九";break;}return a;}public static String today() {Calendar today = Calendar.getInstance(Locale.SIMPLIFIED_CHINESE);int year = today.get(Calendar.YEAR);int month = today.get(Calendar.MONTH) + 1;int date = today.get(Calendar.DATE);long[] l = calElement(year, month, date);StringBuffer sToday = new StringBuffer();try {sToday.append(sdf.format(today.getTime()));sToday.append(" \n");sToday.append(" \n");sToday.append(" \n");sToday.append(" 农历");sToday.append(cyclical(year));sToday.append('(');sToday.append(AnimalsYear(year));sToday.append(")年");sToday.append(" \n");sToday.append(" ");sToday.append(nStr1[(int) l[1]]);sToday.append("月");sToday.append(getChinaDate((int) (l[2])));return sToday.toString();} finally {sToday = null;}}private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy 年M月d日 EEEEE");public void mouseEntered(MouseEvent e) {}public void mouseExited(MouseEvent e) {}public void mousePressed(MouseEvent e) {}public void mouseReleased(MouseEvent e) { }}。

农历时间日期代码

农历时间日期代码

农历时间日期<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>单行带农历的日期时间代码</title></head><body><SCRIPT language=JavaScript><!--function CalConv(){FIRSTYEAR = 1998;LASTYEAR = 2031;today = new Date();SolarYear = today.getFullYear();SolarMonth = today.getMonth() + 1;SolarDate = today.getDate();Weekday = today.getDay();LunarCal = [new tagLunarCal( 27, 5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ),new tagLunarCal( 46, 0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ), /* 88 */ new tagLunarCal( 35, 0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ), /* 89 */ new tagLunarCal( 23, 4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 42, 0, 1, 4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 31, 0, 2, 9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),new tagLunarCal( 21, 2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), /* 93 */ new tagLunarCal( 39, 0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 28, 7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ),new tagLunarCal( 48, 0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ),new tagLunarCal( 37, 0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 97 */ new tagLunarCal( 25, 5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),new tagLunarCal( 44, 0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),new tagLunarCal( 33, 0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 22, 4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), /* 101 */ new tagLunarCal( 40, 0, 1, 2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 30, 9, 2, 7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),new tagLunarCal( 49, 0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1 ),new tagLunarCal( 38, 0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), /* 105 */ new tagLunarCal( 27, 6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ),new tagLunarCal( 46, 0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0 ),new tagLunarCal( 35, 0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ),new tagLunarCal( 24, 4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), /* 109 */new tagLunarCal( 42, 0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 31, 0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 21, 2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),new tagLunarCal( 40, 0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), /* 113 */new tagLunarCal( 28, 6, 2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ),new tagLunarCal( 47, 0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 ),new tagLunarCal( 36, 0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ),new tagLunarCal( 25, 5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), /* 117 */new tagLunarCal( 43, 0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ),new tagLunarCal( 32, 0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0 ),new tagLunarCal( 22, 3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ) ];/* 民國年每月之日數all by */SolarCal = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];/* 民國年每月之累積日數, 平年與閏年*/SolarDays = [ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397 ];if ( SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR ) return 1;sm = SolarMonth - 1;if ( sm < 0 || sm > 11 ) return 2;leap = GetLeap( SolarYear );if ( sm == 1 )d = leap + 28;elsed = SolarCal[sm];if ( SolarDate < 1 || SolarDate > d ) return 3;y = SolarYear - FIRSTYEAR;acc = SolarDays[ leap*14 + sm ] + SolarDate;kc = acc + LunarCal[y].BaseKanChih;Kan = kc % 10;Chih = kc % 12;Age = kc % 60;if ( Age < 22 )Age = 22 - Age;elseAge = 82 - Age;if ( acc <= LunarCal[y].BaseDays ) {y--;LunarYear = SolarYear - 1;leap = GetLeap( LunarYear );sm += 12;acc = SolarDays[leap*14 + sm] + SolarDate;}elseLunarYear = SolarYear;l1 = LunarCal[y].BaseDays;for ( i=0; i<13; i++ ) {l2 = l1 + LunarCal[y].MonthDays[i] + 29;if ( acc <= l2 ) break;l1 = l2;}LunarMonth = i + 1;LunarDate = acc - l1;im = LunarCal[y].Intercalation;if ( im != 0 && LunarMonth > im ) {LunarMonth--;if ( LunarMonth == im ) LunarMonth = -im;}if ( LunarMonth > 12 ) LunarMonth -= 12;today=new Date();function initArray(){this.length=initArray.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=initArray.arguments[i] }var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); document.write("", today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日&nbsp;",d[today.getDay()+1],"");months = ["一","二","三","四","五","六","七","八","九","十","十一","十二"];days = ["初一","初二","初三","初四","初五","初六","初七","初八","初九","初十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十","廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十"];document.write( "&nbsp;农历"+months[LunarMonth-1]+"月" + days[LunarDate-1] + "");return 0;}/* 求此民國年是否為閏年, 返回0 為平年, 1 為閏年*/function GetLeap( year ){if ( year % 400 == 0 )return 1;else if ( year % 100 == 0 )return 0;else if ( year % 4 == 0 )return 1;elsereturn 0;}function tagLunarCal( d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) { this.BaseDays = d; /* 到民國1 月1 日到農曆正月初一的累積日數*/this.Intercalation = i; /* 閏月月份. 0==此年沒有閏月*/this.BaseWeekday = w; /* 此年民國1 月1 日為星期幾再減1 */this.BaseKanChih = k; /* 此年民國1 月1 日之干支序號減1 */this.MonthDays = [ m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13 ]; /* 此農曆年每月之大小, 0==小月(29日), 1==大月(30日) */}//--></SCRIPT><a target=_blank href=><FONT color=#2b68a7><SCRIPT>CalConv();</SCRIPT></FONT></a></body></html>本代码由<a href=>网页特效网</a>提供QQ菜单似的下拉门<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><title>下拉滚动门</title><style type="text/css">body{margin:10px;padding:10px;}body,td,div,span,li{font-size:12px;}.title01,.title02{color:#fff;font-weight:bold;}#DoorP{border:12px solid #eee; width:150px;height:300px;padding:4px; background:#fff;}.title01{width:100%;height:25px; background:#00ccff; cursor:pointer;}.title02{width:100%;height:25px; background:#99cc00; cursor:pointer;}.content{background:#eee;border-bottom:2px solid #fff; overflow:hidden;color:#666;padding-left:4px;padding-right:4px;line-height:18px;}</style><!--棕:#eee;蓝:#00ccff;绿:#99cc00;--></head><body><div id="DoorP"><table><tr><td>第一层信息</td></tr></table><div class="content">十三妖<br/>十三妖<br/>十三妖<br/></div><table><tr><td>第二层信息</td></tr></table><div class="content"> ThirdteenDevil</div><table><tr><td>第三层信息</td></tr></table><div class="content">devil13th</div></div><script type="text/javascript">var open = 2;// 设置初始打开的层序号var openState = new Array();var closeState = new Array();var dH = 220;function $(id){if(document.getElementById(id)) {return document.getElementById(id); }else{alert("没有找到!");}}function $tag(id,tagName){return $(id).getElementsByTagName(tagName)}function closeMe(Cid,Oid){var h = parseInt(Ds[Cid].style.height);//alert(h);if(h > 0){h = h - Math.ceil(h/3);Ds[Cid].style.height = h+"px";}else{openMe(Oid);clearTimeout(closeState[Cid]);return false;}closeState[Cid] = setTimeout("closeMe("+Cid+","+Oid+")"); }function openMe(Oid){var h = parseInt(Ds[Oid].style.height);//alert(h);if(h < dH){h = h + Math.ceil((dH-h)/3);Ds[Oid].style.height = h+"px";}else{clearTimeout(openState[Oid]);return false;}openState[Oid] = setTimeout("openMe("+Oid+")");}var Ds = $tag("DoorP","div");var Ts = $tag("DoorP","table");if(Ds.length != Ts.length){alert("标题和内容数目不相同!");}for(var i = 0 ; i < Ds.length ; i++){if(i==open){Ds[i].style.height = dH+"px";Ts[i].className="title01";}else{Ds[i].style.height = "0px";Ts[i].className="title02";}Ts[i].value = i;Ts[i].onclick = function(){if(open==this.value){return false;}Ts[open].className="title02";Ts[this.value].className="title01";for(var i = 0 ; i < openState.length ; i++){clearTimeout(openState[i]);clearTimeout(closeState[i]);}closeMe(open,this.value);//openMe(this.value);open = this.value;}}//直接打开层函数function showDiv(id){Ds[id].style.height=dH+"px";Ds[open].style.height="0px";open = id;}//渐渐打开层函数</script></body></html>本代码由<a href=>网页特效网</a>提供文字的折叠与展开<div align="center"><table border="0" width="300" cellpadding="0" style="border-collapse: collapse" id="table1" bgcolor="#F3F3F3" cellspacing="10"><tr><td valign="top" style="line-height: 150%"><div class="block" id="smallContent" style="display:block"><span style="font-size: 9pt"> <b>专辑介绍:</b>青春光影是由中国80后影像精英共同组建的新媒体影视摄制机构。

老黄历吉日吉时查询接口实现及代码示例

老黄历吉日吉时查询接口实现及代码示例

老黄历吉日吉时查询接口实现及代码示例环境搭建什么的就不写了,因为网上的教程是很多的,随便搜一下即可。

下面直接从第一个app应用开始详细记录我的android学习之旅1.建立第一个app在eclipse中,File--->New--->Android Application Project新建一个android应用项目。

Application Name是要显示给其他人看的应用名称,Project Name是自己开发能看到的项目名称,package name就和java中差不多。

Minimum Required SDK 是能支持的最低版本的安卓SDK,越低越好。

Target SDK 翻译过来就是目标SDK,当然是越高越好Compile With 就和Target SDK的版本一样就行,然后一路Next 即可。

到此为止,这个Adnroid 项目已经是一个基本的Hello World程序了。

2.执行android程序这一节学习的是如何在android模拟器上安装并且运行自己的应用。

运行之前,先要认识项目里的几个文件和目录:AndroidManifest.xml描述了应用程序的基本特性并且定义了每一个组件。

其中有一个<uses-sdk>,使用android:minSdkVersion和android:targetSdkVersion两个属性来声明你的应用对不同Android 版本的兼容性。

<uses-sdk&#160;&#160;&#160; android:minSdkVersion=&#160;&#160;&#160; android:targetSdkVersion= />src/是存放主要源代码的文件夹,默认情况下,里面会包括一个Activity类,这个类会在点击应用程序图标启动的时候运行res/包含一些存放资源文件的目录例如:drawable-hdpi/&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160; 存放适用于HDPI屏幕的图片素材,同理其他文件夹存放适用于其他屏幕的图片素材layout/&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160; 存放用户定义界面的文件values/&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160; 存放其他xml 文件,也是资源的集合,例如字符串和颜色的定义右击项目,点击run Adnroid application ,运行第一个android 程序,这是一个很开心的尝试,android的一小步,自己的一大步。

.NET4.0 日历控件

.NET4.0  日历控件
DayNameFormat="{Firstletter|FirstTwoLetters|Full|Short}"
FirstDayOfWeek="{Default,Monday,Tuesday,Wednesday,Thursday,
Friday,Saturday,Sunday}"
NextMonthText="…"
ShowNextPrevMonth="True" NextMonthText="[Next]"
SelectedDayStyle-BackColor="#DBDBDB"
OnSelectionChanged="calA_SC"/>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
4.0
Calendar日历控件用于在浏览器中显示日历,该控件可显示某个月的日历并允许用户选择日期,也可以跳到前一个或下一个月。Calendar日历控件的声明语法如下所示,基本属性如表6-15所示。
<ASP:Calendar Runat="Server" Id="…"
Cellpadding="n"
用于选择一周或整个月的链接的列的样式。
下面是一个简单使用日历控件的实例,代码如下所示。
文件名:Calendar.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calendar.aspx.cs" Inherits="Calendar" %>

python生日提醒_Python实现农历生日提醒功能

python生日提醒_Python实现农历生日提醒功能

python生日提醒_Python实现农历生日提醒功能农历生日提醒是一种非常实用的功能,能够帮助我们记住家人和朋友的农历生日,并在特定日期提醒我们发送祝福或者准备礼物。

在这篇文章中,我将使用Python来实现农历生日提醒功能。

``````安装完成后,我们可以开始编写代码了。

首先,我们需要引入需要的库:```pythonimport tkinter as tkfrom lunarcalendar import Converter, Solar```接下来,我们需要定义一个函数来获取当前的农历日期:```pythondef get_lunar_date(:solar = Solar(today.year, today.month, today.day)lunar = Converter(.solar_to_lunar(solar)return lunar```接下来,我们需要定义一个函数来检查是否有农历生日需要提醒,并在有生日需要提醒时弹出一个消息框:```pythondef check_birthday(:lunar_date = get_lunar_datelunar_month = lunar_date.monthlunar_day = lunar_date.dayif (lunar_month, lunar_day) in birthday_dict:name = birthday_dict[(lunar_month, lunar_day)]message = f"今天是{name}的农历生日!"tk.messagebox.showinfo("生日提醒", message)```在该函数中,我们首先获取当前的农历日期。

然后,我们使用获取的农历日期作为键来查找生日字典birthday_dict中是否有对应的生日。

接下来,我们需要定义一个函数来添加生日信息到生日字典:```pythondef add_birthday(:name = name_entry.getdate = date_entry.getlunar_date = Converter(.solar_to_lunar(Solar(lunar_date.year, lunar_date.month, lunar_date.day))birthday_dict[(lunar_date.month, lunar_date.day)] = namename_entry.delete(0, tk.END)date_entry.delete(0, tk.END)```在该函数中,我们首先从输入框中获取生日人的姓名和农历日期。

.NET4.0 简单的日历控件

.NET4.0 简单的日历控件

4.0 简单的日历控件在网页中,用户可以在页头部位插入一个日历控件,方便访问者随时了解当前日期信息。

并且有些网页中,除了插入日历内容外,还包含有天气信息等等。

(1)在窗口中,执行【文件】|【新建】|【项目】命令。

在弹出的【新建项目】对话框中,选择Web模板,并在中间栏中选择【 空Web应用程序】选项。

然后,再修改【名称】为show_date,单击【确定】按钮,如图8-25所示。

图8-25 创建项目(2)在【解决方案资源管理器】中,右击站点目录,并执行【添加新项】命令。

在弹出的【添加新项】对话框中,选择【Visual C#】模板,并选择【Web窗体】选项,单击【添加】按钮,如图8-26所示。

图8-26 添加窗体页(3)再在【解决方案资源管理器】中,右击站点目录,并执行【添加新项】命令。

在弹出的【添加新项】对话框中,选择【Visual C#】模板,并选择【Web用户控件】选项。

然后,将【名称】修改为date,并单击【添加】按钮,如图8-27所示。

图8-27 添加用户控件(4)展开date.ascx文件,并双击date.ascx.cs文件,在编辑器中编写获取日期、农历日期、星期等信息。

详细代码如下:(5)再双击date.ascx文件,并在编辑器中,编写如下代码。

该文件用于显示日历内容。

而由于用户不能直接访问该文件,所以必须通过加载到窗体页中查看效果。

(6)双击Default.aspx文件,并在该文件中,加载所设计的用户按钮,来查看(7)单击【启动调试】按钮,即可浏览窗体页中所加载的控件效果,如图8-28所示。

用户还可以在该控件中,添加时间、天气信息等内容。

这样,这个控件就可以直接应该到不同网页中。

图8-28 显示控件。

C# .NET常用显示日期时间、农历、生肖的日历类

C# .NET常用显示日期时间、农历、生肖的日历类

using System;using System.Collections.Generic;using System.Text;using System.xmxxxxl;using System.Runtime.InteropServices; namespace mons{/// <summary>/// 常用显示日期时间、农历、生肖的日历类 /// </summary>public class CCalendar{/// <summary>/// 结构。

日期对象/// </summary>struct structDate{public int year;public int month;public int day;public bool isLeap; //是否闰月public int yearCyl; //年干支public int monthCyl; //月干支public int dayCyl; //日干支}/// <summary>/// 结构。

完整的日期对象/// </summary>public struct StructDateFullInfo{/// <summary>/// 公历年/// </summary>public int Year;/// <summary>/// 公历月/// </summary>public int Month;/// <summary>/// 公历日/// </summary>public int Day;/// <summary>/// 是否闰月/// </summary>public bool IsLeap; //是否闰月/// <summary>/// 农历年/// </summary>public int Cyear; //农历年/// <summary>/// 农历年名称/// </summary>public string Scyear; //农历年名称 /// <summary>/// 干支/// </summary>public string CyearCyl; //干支年/// <summary>/// 农历月/// </summary>public int Cmonth; //农历月/// <summary>/// 农历月名称/// </summary>public string Scmonth; //农历月名称 /// <summary>/// 干支月/// </summary>public string CmonthCyl; //干支月/// <summary>/// 农历日/// </summary>public int Cday; //农历日/// <summary>/// 农历日名称/// </summary>public string Scday; //农历日名称 /// <summary>/// 干支日/// </summary>public string CdayCyl; //干支日/// <summary>/// 节气/// </summary>public string solarterm; //节气/// <summary>/// 星期几/// </summary>public string DayInWeek; //星期几/// <summary>/// 节日/// </summary>public string Feast; //节日public string Info; //系统问候语/// <summary>/// 主题图片/// </summary>public string Image; //主题图片/// <summary>/// 完整的日期信息/// </summary>public string Fullinfo; //完整的日期信息/// <summary>/// 有特别的问候语吗/// </summary>public bool SayHello; //有特别的问候语吗?}#region 农历相关数据//农历月份信息int[] lunarInfo = newint[]{0x04bd80x04ae00x0a5700x054d50x0d2600x0d9500x165540x056a00x09ad00x055d2 0x04ae00x0a5b60x0a4d00x0d2500x1d2550x0b5400x0d6a00x0ada20x095b00x149770x049700x0a4b00x0b4b50x06a500x06d400x1ab540x02b600x095700x052f20x049700x065660x0d4a00x0ea500x06e950x05ad00x02b600x186e30x092e00x1c8d70x0c9500x0d4a00x1d8a60x0b5500x056a00x1a5b40x025d00x092d00x0d2b20x0a9500x0b5570x06ca00x0b5500x153550x04da00x0a5d00x145730x052d00x0a9a80x0e9500x06aa00x0aea60x0ab500x04b600x0aae40x0a5700x052600x0f2630x0d9500x05b570x056a00x096d00x04dd50x04ad00x0a4d00x0d4d40x0d2500x0d5580x0b5400x0b5a00x195a60x095b00x049b00x0a9740x0a4b00x0b27a0x06a500x06d400x0af460x0ab600x095700x04af50x049700x064b00x074a30x0ea500x06b580x055c00x0ab600x096d50x092e00x0c9600x0d9540x0d4a00x0da500x075520x056a00x0abb70x025d00x092d00x0cab50x0a9500x0b4a00x0baa40x0ad500x055d90x04ba00x0a5b00x151760x052b00x0a9300x079540x06aa00x0ad500x05b520x04b600x0a6e60x0a4e00x0d2600x0ea650x0d5300x05aa00x076a30x096d00x04bd70x04ad00x0a4d00x1d0b60x0d2500x0d5200x0dd450x0b5a00x056d00x055b20x049b00x0a5770x0a4b00x0aa500x1b2550x06d200x0ada0};//公历月份int[] solarMonth = new int[] { 0 31 28 31 30 31 30 31 31 30 31 30 31 };string[] cMonthName = new string[] { "" "正月" "二月" "三月" "四月" "五月" "六月" "七月" "八月" "九月" "十月" "十一月" "十二月" };//天干string[] gan = new string[] { "甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸" };//地支string[] zhi = new string[] { "子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥" };//生肖string[] animals = new string[] { "鼠" "牛" "虎" "兔" "龙" "蛇" "马" "羊" "猴" "鸡" "狗" "猪" }; //节气string[] solarTerm = new string[] {"小寒""大寒""立春""雨水""惊蛰""春分""清明""谷雨""立夏""小满""芒种""夏至""小暑""大暑""立秋""处暑""白露""秋分""寒露""霜降""立冬""小雪""大雪""冬至"};//节气对应数值?int[] solarTermInfo = new int[] {021208424676383685337107014128867150921173149195551218072240693263343285989308563331033353350375494397447419210440795 462224483532504758};//农历日子string[] nStr1 = new string[] { "日" "一" "二" "三" "四" "五" "六" "七" "八" "九" "十" };string[] nStr2 = new string[] { "初" "十" "廿" "卅" "" };//公历月份名称string[] monthName = new string[] { "JAN" "FEB" "MAR" "APR" "MAY" "JUN" "JUL" "AUG" "SEP" "OCT" "NOV" "DEC" };#endregionpublic CCalendar() { }//传回农历 y 年的总天数private int GetLYearDays(int y){int sum = 348;for (int i = 0x8000; i > 0x8; i >>= 1){sum += ((lunarInfo[y - 1900] & i) > 0) ? 1 : 0;}return sum + GetLeapDays(y);}//传回农历 y 年 m 月的总天数private int GetLMonthDays(int y int m){return (((lunarInfo[y - 1900] & (0x10000 >> m)) > 0) ? 30 : 29); }//传回农历 y 年闰哪个月 1-12 没闰传回 0private int GetLeapMonth(int y){return (lunarInfo[y - 1900] & 0xf);}//传回农历 y 年闰月的天数private int GetLeapDays(int y){if (GetLeapMonth(y) > 0){return (((lunarInfo[y - 1900] & 0x10000) > 0) ? 30 : 29);}else{return 0;}}//得到农历日期private structDate GetLunar(DateTime date){structDate sd;int i = 0;int leap = 0 temp = 0;DateTime baxxxxseDate = new DateTime(1900 1 31); //基准时间int offset = (date - baxxxxseDate).Days; //与基准时间相隔天数 sd.dayCyl = offset + 40;sd.monthCyl = 14;for (i = 1900; i < 2050 && offset > 0; i++){temp = GetLYearDays(i);offset -= temp;sd.monthCyl += 12;}if (offset < 0){offset += temp;i--;sd.monthCyl -= 12;}sd.year = i;sd.yearCyl = i - 1864;//闰哪个月leap = GetLeapMonth(i);sd.isLeap = false;for (i = 1; i < 13 && offset > 0; i++){if (leap > 0 && i == (leap + 1) && sd.isLeap == false) {--i;sd.isLeap = true;temp = GetLeapDays(sd.year);}else{temp = GetLMonthDays(sd.year i);}//解除闰月if (sd.isLeap == true && i == (leap + 1)){sd.isLeap = false;}offset -= temp;if (sd.isLeap == false){sd.monthCyl++;}}if (offset == 0 && leap > 0 && i == leap + 1){if (sd.isLeap){sd.isLeap = false;}else{sd.isLeap = true;--i;--sd.monthCyl;}}if (offset < 0){offset += temp;--i;--sd.monthCyl;}sd.month = i;sd.day = offset + 1;}//传回公历 y 年 m 月的天数private int SolarDays(int y int m){if (m == 2){return (((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)) ? 29 : 28); }else{return (solarMonth[m]);}}//传入 offset 传回天干地支 0=甲子private string Cyclical(int num){return (gan[num % 10] + zhi[num % 12]);}//某年的第n个节气为几日(从0即小寒起算)// n:节气下标private int GetSolarTermDay(int y int n){double minutes = 0;//1900年1月6日:小寒DateTime baxxxxseDate = new DateTime(1900 1 6 2 5 0);minutes = 525948.766245 * (y - 1900) + solarTermInfo[n - 1];DateTime veryDate = baxxxxseDate.AddMinutes(minutes);return veryDate.Day;}//农历日子private string GetCDay(int d){string s = "";switch (d){case 10:s = "初十";break;case 20:s = "二十";break;case 30:s = "三十";break;default:s = nStr2[(int)System.Math.Floor((double)d / 10)];s += nStr1[d % 10];break;}return (s);}/// <summary>/// 得到日期信息/// </summary>/// <param name="d">待检查的日子</param>/// <returns>日期信息</returns>public StructDateFullInfo GetDateInfo(DateTime d){string calendarxmxxxxlData =FileUtil.ReadFileFromemxxxxbedded("mons." + "CCalendarData.xmxxxxl");StructDateFullInfo dayinfo;structDate day = GetLunar(d);dayinfo.IsLeap = day.isLeap;dayinfo.Year = d.Year;dayinfo.Cyear = day.year;dayinfo.Scyear = animals[(day.year - 4) % 12];dayinfo.CyearCyl = Cyclical(day.yearCyl);//干支年dayinfo.Month = d.Month;dayinfo.Cmonth = day.month;dayinfo.Scmonth = cMonthName[day.month];dayinfo.CmonthCyl = Cyclical(day.monthCyl);//干支月 dayinfo.Day = d.Day;dayinfo.Cday = day.day;dayinfo.Scday = GetCDay(day.day);//日子dayinfo.CdayCyl = Cyclical(day.dayCyl);//干支日switch (d.DayOfWeek){case DayOfWeek.Sunday:dayinfo.DayInWeek = "星期日";break;case DayOfWeek.Monday:dayinfo.DayInWeek = "星期一";break;case DayOfWeek.Tuesday:dayinfo.DayInWeek = "星期二";break;case DayOfWeek.Wednesday:dayinfo.DayInWeek = "星期三";break;case DayOfWeek.Thursday:dayinfo.DayInWeek = "星期四";break;case DayOfWeek.Friday:dayinfo.DayInWeek = "星期五";break;case DayOfWeek.Saturday:dayinfo.DayInWeek = "星期六";break;default:dayinfo.DayInWeek = "星期?";break;}//节气//每个月有两个节气int d1 = GetSolarTermDay(d.Year d.Month * 2 - 1);int d2 = GetSolarTermDay(d.Year d.Month * 2);if (dayinfo.Day == d1){dayinfo.solarterm = solarTerm[d.Month * 2 - 2];}else if (dayinfo.Day == d2){dayinfo.solarterm = solarTerm[d.Month * 2 - 1];}else{dayinfo.solarterm = "";}//节日及问候语 = "";dayinfo.Feast = "";dayinfo.Image = "";dayinfo.SayHello = false;xmxxxxlDocument feastdoc = new xmxxxxlDocument();feastdoc.Loadxmxxxxl(calendarxmxxxxlData);//公历xmxxxxlNodeList nodeList = feastdoc.SelectNodes("descendant::AD/feast[@day='" + d.ToString("MMdd") + "']");foreach (xmxxxxlNode root in nodeList){dayinfo.Feast += root.Attributes["name"].InnerText + " ";if (root.Attributes["sayhello"].InnerText == "yes"){//需要显示节日问候语 = root["hello"].InnerText;//看看是否需要计算周年if (root["startyear"] != null){int startyear = Convert.ToInt32(root["startyear"].InnerText); = .Replace("_YEARS_" (d.Year - startyear).ToString()); }dayinfo.Image = root["img"].InnerText;dayinfo.SayHello = true;}}//农历string smmdd = "";smmdd = (dayinfo.Cmonth.ToString().Length == 2) ? dayinfo.Cmonth.ToString() : ("0" + dayinfo.Cmonth.ToString());smmdd += (dayinfo.Cday.ToString().Length == 2) ? dayinfo.Cday.ToString() : ("0" + dayinfo.Cday.ToString());xmxxxxlNode feast = feastdoc.SelectSingleNode("descendant::LUNAR/feast[@day='" + smmdd + "']");if (feast != null){dayinfo.Feast += feast.Attributes["name"].InnerText;if (feast.Attributes["sayhello"].InnerText == "yes"){//需要显示节日问候语 += feast["hello"].InnerText;dayinfo.Image = feast["img"].InnerText;dayinfo.SayHello = true;}}//普通日子或没有庆贺语if ( == ""){feast = feastdoc.SelectSingleNode("descendant::NORMAL/day[@time1<'" +d.ToString("HHmm") + "']");if (feast != null){ = feast["hello"].InnerText;dayinfo.Image = feast["img"].InnerText;}}dayinfo.Fullinfo = dayinfo.Year.ToString() + "年" + dayinfo.Month.ToString() + "月" + dayinfo.Day.ToString() + "日";dayinfo.Fullinfo += dayinfo.DayInWeek;dayinfo.Fullinfo += " 农历" + dayinfo.CyearCyl + "[" + dayinfo.Scyear + "]年";if (dayinfo.IsLeap){dayinfo.Fullinfo += "闰";}dayinfo.Fullinfo += dayinfo.Scmonth + dayinfo.Scday; if (dayinfo.solarterm != ""){dayinfo.Fullinfo += " " + dayinfo.solarterm;}return dayinfo;}/// <summary>/// 得到精简日期信息(不含节日)/// </summary>/// <param name="d">待检查的日子</param>/// <returns>日期信息</returns>public StructDateFullInfo GetDateTidyInfo(DateTime d) {StructDateFullInfo dayinfo;structDate day = GetLunar(d);dayinfo.IsLeap = day.isLeap;dayinfo.Year = d.Year;dayinfo.Cyear = day.year;dayinfo.Scyear = animals[(day.year - 4) % 12];dayinfo.CyearCyl = Cyclical(day.yearCyl);//干支年dayinfo.Month = d.Month;dayinfo.Cmonth = day.month;dayinfo.Scmonth = cMonthName[day.month];dayinfo.CmonthCyl = Cyclical(day.monthCyl);//干支月 dayinfo.Day = d.Day;dayinfo.Cday = day.day;dayinfo.Scday = GetCDay(day.day);//日子dayinfo.CdayCyl = Cyclical(day.dayCyl);//干支日switch (d.DayOfWeek){case DayOfWeek.Sunday:dayinfo.DayInWeek = "星期日";break;case DayOfWeek.Monday:dayinfo.DayInWeek = "星期一";break;case DayOfWeek.Tuesday:dayinfo.DayInWeek = "星期二";break;case DayOfWeek.Wednesday:dayinfo.DayInWeek = "星期三";break;case DayOfWeek.Thursday:dayinfo.DayInWeek = "星期四";break;case DayOfWeek.Friday:dayinfo.DayInWeek = "星期五";break;case DayOfWeek.Saturday:dayinfo.DayInWeek = "星期六";break;default:dayinfo.DayInWeek = "星期?";break;} = "";dayinfo.Feast = "";dayinfo.Image = "";dayinfo.SayHello = false;//节气//每个月有两个节气int d1 = GetSolarTermDay(d.Year d.Month * 2 - 1); int d2 = GetSolarTermDay(d.Year d.Month * 2);if (dayinfo.Day == d1){dayinfo.solarterm = solarTerm[d.Month * 2 - 2]; }else if (dayinfo.Day == d2){dayinfo.solarterm = solarTerm[d.Month * 2 - 1];}else{dayinfo.solarterm = "";}dayinfo.Fullinfo = dayinfo.Year.ToString() + "年" + dayinfo.Month.ToString() + "月" + dayinfo.Day.ToString() + "日";dayinfo.Fullinfo += " " + dayinfo.DayInWeek;dayinfo.Fullinfo += " 农历" + dayinfo.CyearCyl + "(" + dayinfo.Scyear + ")年";if (dayinfo.IsLeap){dayinfo.Fullinfo += "闰";}dayinfo.Fullinfo += dayinfo.Scmonth + dayinfo.Scday;if (dayinfo.solarterm != ""){dayinfo.Fullinfo += " " + dayinfo.solarterm;}return dayinfo;}}}。

C# .NET中国农历年处理类

C# .NET中国农历年处理类

using System;using System.Collections.Generic;using System.Text;using System.Globalization;namespace mons{/// <summary>/// 中国农历年处理类/// </summary>public class ChineseCalendar{/// <summary>/// 实例化一个 ChineseLunisolarCalendar/// </summary>private static ChineseLunisolarCalendar cCalendar = new ChineseLunisolarCalendar();/// <summary>/// 获取农历当前日期/// </summary>/// <returns></returns>public static string GetChineseDateTimeNow(){return GetChineseDateTime(DateTime.Now);}/// <summary>/// 根据公历获取农历日期/// </summary>/// <param name="datetime">公历日期</param>/// <returns></returns>public static string GetChineseDateTime(DateTime datetime){int lyear = cCalendar.GetYear(datetime);int lmonth = cCalendar.GetMonth(datetime);int lday = cCalendar.GetDayOfMonth(datetime);//获取闰月, 0 则表示没有闰月int leapMonth = cCalendar.GetLeapMonth(lyear);bool isleap = false;if (leapMonth > 0){if (leapMonth == lmonth){//闰月isleap = true;lmonth--;}else if (lmonth > leapMonth){lmonth--;}}return string.Concat(GetLunisolarYear(lyear) "年" isleap ? "闰" : string.Empty GetLunisolarMonth(lmonth) "月" GetLunisolarDay(lday));}/// <summary>/// 返回农历日期/// </summary>public static string Now{get{return GetChineseDateTimeNow();}}/// <summary>/// 最大支持日期/// </summary>public static DateTime MaxSupportedDateTime{get{return cCalendar.MaxSupportedDateTime;}}/// <summary>/// 最小支持日期/// </summary>public static DateTime MinSupportedDateTime{get{return cCalendar.MinSupportedDateTime;}}/// <summary>/// 返回生肖/// </summary>/// <param name="datetime">公历日期</param>/// <returns></returns>public static string GetShengXiao(DateTime datetime){return shengxiao[cCalendar.GetTerrestrialBranch(cCalendar.GetSexagenaryYear(datetime)) - 1];}#region 农历年/// <summary>/// 十天干/// </summary>private static string[] tiangan = { "甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸" };/// <summary>/// 十二地支/// </summary>private static string[] dizhi = { "子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥" }; /// <summary>/// 十二生肖/// </summary>private static string[] shengxiao = { "鼠" "牛" "虎" "免" "龙" "蛇" "马" "羊" "猴" "鸡" "狗" "猪" };/// <summary>/// 返回农历天干地支年/// </summary>/// <param name="year">农历年</param>/// <returns></returns>public static string GetLunisolarYear(int year){if (year > 3){int tgIndex = (year - 4) % 10;int dzIndex = (year - 4) % 12;return string.Concat(tiangan[tgIndex] dizhi[dzIndex] "[" shengxiao[dzIndex] "]");}throw new ArgumentOutOfRangeException("无效的年份!");}#endregion#region 农历月/// <summary>/// 农历月/// </summary>private static string[] months = { "正" "二" "三" "四" "五" "六" "七" "八" "九" "十" "十一" "十二(腊)" };/// <summary>/// 返回农历月/// </summary>/// <param name="month">月份</param>/// <returns></returns>public static string GetLunisolarMonth(int month){if (month < 13 && month > 0){return months[month - 1];}throw new ArgumentOutOfRangeException("无效的月份!");}#endregion#region 农历日/// <summary>////// </summary>private static string[] days1 = { "初" "十" "廿" "三" };/// <summary>/// 日/// </summary>private static string[] days = { "一" "二" "三" "四" "五" "六" "七" "八" "九" "十" };/// <summary>/// 返回农历日/// </summary>/// <param name="day"></param>/// <returns></returns>public static string GetLunisolarDay(int day){if (day > 0 && day < 32){if (day != 20 && day != 30){return string.Concat(days1[(day - 1) / 10] days[(day - 1) % 10]);}else{return string.Concat(days[(day - 1) / 10] days1[1]);}}throw new ArgumentOutOfRangeException("无效的日!"); }#endregion}}。

日历代码_精品文档

日历代码_精品文档

日历代码
1. 简介
日历是用来显示日期的一种工具。

在计算机编程中,我们可以通过编写代码来生成和显示日历。

本文将介绍如何用Python编写一个简单的日历代码。

我们将使用Python的datetime和calendar模块来实现这个功能。

2. 实现步骤
2.1 导入模块
我们首先需要导入Python的datetime和calendar模块。

datetime模块提供了日期和时间的相关功能,而calendar模块则提供了生成日历的功能。

import datetime
import calendar
2.2 获取当前日期
我们可以使用datetime模块的date类来获取当前日期。

today = datetime.date.today()
2.3 获取当前月份的日历
我们可以使用calendar模块的monthcalendar函数来生成当前月份的日历。

cal = calendar.monthcalendar(today.year, today.month)
2.4 打印日历
我们可以使用循环遍历生成的日历列表,并打印出每个日期。

```python for week in cal: for day in week: if day == 0: print(。

ASP.NETCalendar日历(日期)控件使用方法

ASP.NETCalendar日历(日期)控件使用方法

Calendar⽇历(⽇期)控件使⽤⽅法Calendar 控件显⽰⼀个⽇历,⽤户可通过该⽇历导航到任意⼀年的任意⼀天。

当 ⽹页运⾏时,Calendar 控件以HTML 表格的形式呈现。

因此,该控件的许多属性与多种不同的表格格式相符。

在这些属性中,有⼏个在⼀些低版本的浏览器中不能得到完全⽀持,因此在这些浏览器中并不能使⽤所有的格式功能。

使⽤ Calendar 控件在⽹页上显⽰⽇历的单个⽉。

该控件使您可以选择⽇期并移到下个⽉或上个⽉。

Calendar 控件⽀持System.Globalization 命名空间中的所有 System.Globalization.Calendar 类型。

除公历以外,这还包括使⽤不同年和⽉系统的⽇历,如 Hjiri ⽇历。

可以通过设置 SelectionMode 属性指定 Calendar 控件是否允许选择单⽇、周或整⽉。

默认情况下,该控件显⽰⽉中各天、周中各天的标头、带有⽉份名和年份的标题、⽤于选择⽉份中各天的链接及⽤于移动到下个⽉和上个⽉的链接。

您可以通过设置控制控件中不同部分的样式的属性,来⾃定义 Calendar 控件的外观。

下表列出了指定控件不同部分的样式的属性。

属性说明DayHeaderStyle为显⽰⼀周中各天的部分指定样式。

DayStyle为显⽰的⽉份中的⽇期指定样式。

NextPrevStyle为标题部分中的导航控件指定样式。

OtherMonthDayStyle为不在当前显⽰的⽉份中的⽇期指定样式。

SelectedDayStyle为⽇历中的选定⽇期指定样式。

SelectorStyle为周和⽉份⽇期选择列指定样式。

TitleStyle为标题部分指定样式。

TodayDayStyle为今天⽇期指定样式。

WeekendDayStyle为周末⽇期指定样式。

也可以显⽰或隐藏控件的不同部分。

下表列出控制显⽰或隐藏哪些部分的属性。

ShowDayHeader显⽰或隐藏显⽰⼀周中各天的部分。

获取阴历(农历)和当前日期的js代码

获取阴历(农历)和当前日期的js代码

获取阴历(农历)和当前⽇期的js代码本⽂为⼤家分享了⼀段js显⽰阴历(农历)和当前⽇期的关键性代码,供⼤家参考,具体内容如下var CalendarData=new Array(100);var madd=new Array(12);var tgString="甲⼄丙丁戊⼰庚⾟壬癸";var dzString="⼦丑寅卯⾠巳午未申⾣戌亥";var numString="⼀⼆三四五六七⼋九⼗";var monString="正⼆三四五六七⼋九⼗冬腊";var weekString="⽇⼀⼆三四五六";var sx="⿏⽜虎兔龙蛇马⽺猴鸡狗猪";var cYear,cMonth,cDay,TheDate;CalendarData = new Array(0xA4B,0x5164B,0x6A5,0x6D4,0x415B5,0x2B6,0x957,0x2092F,0x497,0x60C96,0xD4A,0xEA5,0x50DA9,0x5AD,0x2B6,0x3126E, 0x92E,0x7192D,0xC95,0xD4A,0x61B4A,0xB55,0x56A,0x4155B, 0x25D,0x92D,0x2192B,0xA95,0x7169 madd[0]=0;madd[1]=31;madd[2]=59;madd[3]=90;madd[4]=120;madd[5]=151;madd[6]=181;madd[7]=212;madd[8]=243;madd[9]=273;madd[10]=304;madd[11]=334;function GetBit(m,n){return (m>>n)&1;}function e2c(){TheDate= (arguments.length!=3) ? new Date() : new Date(arguments[0],arguments[1],arguments[2]);var total,m,n,k;var isEnd=false;var tmp=TheDate.getYear();if(tmp<1900){tmp+=1900;}total=(tmp-1921)*365+Math.floor((tmp-1921)/4)+madd[TheDate.getMonth()]+TheDate.getDate()-38;if(TheDate.getYear()%4==0&&TheDate.getMonth()>1) {total++;}for(m=0;;m++){k=(CalendarData[m]<0xfff)?11:12;for(n=k;n>=0;n--){if(total<=29+GetBit(CalendarData[m],n)){isEnd=true; break;}total=total-29-GetBit(CalendarData[m],n);}if(isEnd) break;}cYear=1921 + m;cMonth=k-n+1;cDay=total;if(k==12){if(cMonth==Math.floor(CalendarData[m]/0x10000)+1){cMonth=1-cMonth;}if(cMonth>Math.floor(CalendarData[m]/0x10000)+1){cMonth--;}}}function GetcDateString(){var tmp="";tmp+=tgString.charAt((cYear-4)%10);tmp+=dzString.charAt((cYear-4)%12);tmp+="(";tmp+=sx.charAt((cYear-4)%12);tmp+=")年 ";if(cMonth<1){tmp+="(闰)";tmp+=monString.charAt(-cMonth-1);}else{tmp+=monString.charAt(cMonth-1);}tmp+="⽉";tmp+=(cDay<11)?"初":((cDay<20)?"⼗":((cDay<30)?"廿":"三⼗"));if (cDay%10!=0||cDay==10){tmp+=numString.charAt((cDay-1)%10);}return tmp;}function GetLunarDay(solarYear,solarMonth,solarDay){//solarYear = solarYear<1900?(1900+solarYear):solarYear;if(solarYear<1921 || solarYear>2020){return "";}else{solarMonth = (parseInt(solarMonth)>0) ? (solarMonth-1) : 11;e2c(solarYear,solarMonth,solarDay);return GetcDateString();}}var D=new Date();var yy=D.getFullYear();var mm=D.getMonth()+1;var dd=D.getDate();var ww=D.getDay();var ss=parseInt(D.getTime() / 1000);if (yy<100) yy="19"+yy;function showCal(){document.write(GetLunarDay(yy,mm,dd));}页⾯调⽤代码:<script language="JavaScript" type="text/javascript" src="getCNdate.js"></script><script type="text/javascript">showCal();</script>代码⼆:⽤JavaScript获取当前农历⽇期<script type="text/javascript">var sWeek = new Array("星期⽇","星期⼀","星期⼆","星期三","星期四","星期五","星期六");var dNow = new Date();var CalendarData=new Array(100);var madd=new Array(12);var tgString="甲⼄丙丁戊⼰庚⾟壬癸";var dzString="⼦丑寅卯⾠巳午未申⾣戌亥";var numString="⼀⼆三四五六七⼋九⼗";var monString="正⼆三四五六七⼋九⼗冬腊";var weekString="⽇⼀⼆三四五六" CalendarData = new Array( 0xA4B,0x5164B,0x6A5,0x6D4,0x415B5,0x2B6,0x957,0x2092F,0x497,0x60C96, 0xD4A,0xEA5,0x50DA9,0x5AD,0x2B6,0x3126E, 0x92E,0x7192D,0xC95,0xD4A, 0x61B4A,0xB55,0x56A,0x4155B, 0x25D,0x92D,0x 0x49B,0x41497,0xA4B,0xA164B, 0x6A5,0x6D4,0x615B4,0xAB6,0x957,0x5092F,0x497,0x64B, 0x30D4A,0xEA5,0x80D65,0x5AC,0xAB6,0x5126D,0x92E,0xC96, 0x41A95,0xD4A,0xDA5,0x20B55,0x56A,0x7155B,0x25D,0x92D,0x5192B,0xA95, 0xB4A,0x416AA,0xAD5,0x90AB5,0x4BA,0xA5B, 0x60A57,0x52B,0xA93,0x40E95); madd[0]=0;madd[1]=31;madd[2]=59;madd[3]=90;madd[4]=120;madd[5]=151;madd[6]=181;madd[7]=212;madd[8]=243;madd[9]=273;madd[10]=304;madd[11]=334;function GetBit(m,n) { return (m>>n)&1; }function e2c(){TheDate= (arguments.length!=3) ? new Date() : new Date(arguments[0],arguments[1],arguments[2]);var total,m,n,k;var isEnd=false;var tmp=TheDate.getFullYear();total=(tmp-1921)*365+Math.floor((tmp-1921)/4)+madd[TheDate.getMonth()]+TheDate.getDate()-38; if (TheDate.getYear()%4==0&&TheDate.getMonth()>1) { total++;} for(m=0;;m++) { k=(CalendarData[m]<0xfff)?11:12; for(n=k;n>=0;n--) { if(total<=29+GetBit(C function GetcDateString(){ var tmp=""; tmp+=tgString.charAt((cYear-4)%10);tmp+=dzString.charAt((cYear-4)%12);tmp+="年 ";if(cMonth<1) { tmp+="(闰)"; tmp+=monString.charAt(-cMonth-1); } else {tmp+=monString.charAt(cMonth-1);} tmp+="⽉"; tmp+=(cDay<11)?"初":((cDay<20)?"⼗":((cDay<30)?"廿":"三⼗"));if (cDay%10!=0||cDay==10) { tmp+=numString.charAt((cDay-1)%10); } return tmp;}function GetLunarDay(solarYear,solarMonth,solarDay){if (solarYear<1921 || solarYear>2020) { return "";} else { solarMonth = (parseInt(solarMonth)>0) ? (solarMonth-1) : 11; e2c(solarYear,solarMonth,solarDay); return GetcDateString(); }}var D=new Date();var yy=D.getFullYear();var mm=D.getMonth()+1;var dd=D.getDate();var ww=D.getDay();var ss=parseInt(D.getTime() / 1000);function getFullYear(d){// 修正firefox下year错误yr=d.getYear();if(yr<1000)yr+=1900;return yr;}function showDate() {var sValue = getFullYear(dNow)+"年"+(dNow.getMonth()+1)+"⽉"+dNow.getDate()+"⽇"+" "+sWeek[dNow.getDay()]+" ";sValue+=GetLunarDay(yy,mm,dd);document.getElementById("pDate").innerHTML = sValue;};window.onload=showDate;</script>知道如何获取农历,如何呢获取当前⽇期也很简单。

网页形式的日历代码,很好

网页形式的日历代码,很好

将这本段中文(字体红色),以及这幅日历截图删除,然后将下面的代码另存为html文件,打开即可看到非常好用,内容充实的日历,如果设置于桌面就成为桌面日历。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">><HEAD><TITLE>万年历</TITLE><METAcontent="农历; 阳历; 月历; 节日; 时区; 节气; 八字; 干支; 生肖; gregorian solar; chinese lunar; calendar;"name=keywords><META content=All name=robots><META content="gregorian solar calendar and chinese lunar calendar"name=description><META http-equiv=Content-Type content="text/html; charset=gb2312"><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,2633 43,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758)var nStr1 = new Array('日','一','二','三','四','五','六','七','八','九','十')var nStr2 = new Array('初','十','廿','卅','')var monthName = new Array("1 月","2 月","3 月","4 月","5 月","6 月","7 月","8 月","9 月","10 月","11 月","12 月");//国历节日*表示放假日var sFtv = new Array("0101*元旦","0214 情人节","0308 妇女节","0312 植树节","0315 消费者权益日","0401 愚人节","0501 劳动节","0504 青年节","0512 护士节","0601 儿童节","0701 建党节香港回归纪念","0801 建军节","0808 父亲节","0909 毛泽东逝世纪念","0910 教师节","0928 孔子诞辰","1001*国庆节","1006 老人节","1024 联合国日","1112 孙中山诞辰纪念","1220 澳门回归纪念","1225 圣诞节","1226 毛泽东诞辰纪念")//农历节日*表示放假日var lFtv = new Array("0101*春节!","0115 元宵节","0505 端午节","0707 七夕情人节","0815 中秋节","0909 重阳节","1208 腊八节","1223 小年","0100*除夕")//某月的第几个星期几var wFtv = new Array("0520 母亲节")/*****************************************************************************日期计算*****************************************************************************///====================================== 传回农历y年的总天数function lYearDays(y) {var i, sum = 348for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i)? 1: 0return(sum+leapDays(y))}//====================================== 传回农历y年闰月的天数function leapDays(y) {if(leapMonth(y)) return((lunarInfo[y-1900] & 0x10000)? 30: 29)else return(0)}//====================================== 传回农历y年闰哪个月1-12 , 没闰传回0function 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 .monCylfunction Lunar(objDate) {var i, leap=0, temp=0var baseDate = new Date(1900,0,31)var offset = (objDate - baseDate)/86400000this.dayCyl = offset + 40this.monCyl = 14for(i=1900; i<2050 && offset>0; i++) {temp = lYearDays(i)offset -= tempthis.monCyl += 12}if(offset<0) {offset += temp;i--;this.monCyl -= 12}this.year = ithis.yearCyl = i-1864leap = leapMonth(i) //闰哪个月this.isLeap = falsefor(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 = falseoffset -= tempif(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 = ithis.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)elsereturn(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, tmp2var lDPOS = new Array(3)var n = 0var firstLM = 0sDObj = 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 = lMlDPOS[n++] = i-lD+1}//sYear,sMonth,sDay,week,//lYear,lMonth,lDay,isLeap,//cYear,cMonth,cDaythis[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 )-1tmp2=sTerm(y,m*2+1)-1this[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)-firstLMif(tmp1==-11) tmp1=1if(tmp1 >=0 && tmp1<n) {tmp2 = lDPOS[tmp1] + Number(RegExp.$2) -1if( 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) + '年&nbsp;&nbsp;【'+Animals[(SY-4)%12]+'】';YMBG.innerHTML = "&nbsp;" + SY + "<BR>&nbsp;" + 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 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,cDayif(sObj.innerHTML!='') {sObj.style.cursor = 's-resize';if(cld[d].solarTerms == '' && cld[d].solarFestival == '' && cld[d].lunarFestival == '') festival = '';elsefestival = '<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;}}}//清除详细日期资料function mOut() {if ( cnt >= 1 ) { sw = 0 }if ( sw == 0 ) { snow = 0; dStyle.visibility = "hidden";}else cnt++;}//取得位置function mEvn() {x=event.x;y=event.y;if (document.body.scrollLeft){x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;} if (snow){dStyle.left = x+offsetx-(width/2)dStyle.top = y+offsety}}///////////////////////////////////////////////////////////////////////////function setCookie(name, value) {var today = new Date()var expires = new Date()expires.setTime(today.getTime() + 1000*60*60*24*365)document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() }function getCookie(Name) {var search = Name + "="if(document.cookie.length > 0) {offset = document.cookie.indexOf(search)if(offset != -1) {offset += search.lengthend = document.cookie.indexOf(";", offset)if(end == -1) end = document.cookie.lengthreturn unescape(document.cookie.substring(offset, end))}else return ""}}/////////////////////////////////////////////////////////function initial() {dStyle = detail.style;CLD.SY.selectedIndex=tY-1900;CLD.SM.selectedIndex=tM;drawCld(tY,tM);}//--></SCRIPT><SCRIPT language=VBScript><!--'===== 算世界时间Function TimeAdd(UTC,T)Dim PlusMinus, DST, yIf Left(T,1)="-" Then PlusMinus = -1 Else PlusMinus = 1UTC=Right(UTC,Len(UTC)-5)UTC=Left(UTC,Len(UTC)-4)y = Year(UTC)TimeAdd=DateAdd("n", (Cint(Mid(T,2,2))*60 + Cint(Mid(T,4,2))) * PlusMinus, UTC)'美国日光节约期间: 4月第一个星日00:00 至10月最後一个星期日00:00If Mid(T,6,1)="*" And DateSerial(y,4,(9 - Weekday(DateSerial(y,4,1)) mod 7) ) <= TimeAdd And DateSerial(y,10,31 - Weekday(DateSerial(y,10,31))) >= TimeAdd ThenTimeAdd=CStr(DateAdd("h", 1, TimeAdd))tSave.innerHTML = "R"ElsetSave.innerHTML = ""End IfTimeAdd = CStr(TimeAdd)End Function'--></SCRIPT><STYLE>.todyaColor {BACKGROUND-COLOR: aqua}</STYLE><SCRIPT>if (!yers&&!document.all)event="test"function showtip2(current,e,text){if (document.all&&document.readyState=="complete"){document.all.tip2.innerHTML='<marquee scrolldelay="95" scrollamount="2" behavior="slide" width="397" bgcolor="#FFFFD9" style="border:2px solid #00BF00" align="middle">'+text+'</marquee>'document.all.tip2.style.pixelTop=event.clientY+document.body.scrollTop+18document.all.tip2.style.visibility="visible"}else if (yers){document.tip2.document.nstip.document.write('<b>'+text+'</b>')document.tip2.document.nstip.document.close()currentscroll=setInterval("scrolltip()",0)document.tip2.visibility="show"}}function hidetip2(){if (document.all)document.all.tip2.style.visibility="hidden"else if (yers){clearInterval(currentscroll)document.tip2.visibility="hidden"}}</SCRIPT><META content="MSHTML 5.50.4134.100" name=GENERATOR></HEAD><BODY language=jscript bgColor=#008080 onload=initial();><BR><DIV id=tip2style="LEFT: 120px; VISIBILITY: hidden; COLOR: #910091; POSITION: absolute; HEIGHT: 26px"></DIV><SCRIPT language=JavaScript><!--if(navigator.appName == "Netscape" || parseInt(navigator.appVersion) < 4)document.write("<h1>你的浏览器无法执行此程序。

阴历显示(农历)

阴历显示(农历)

&lt;%'Option Explicit'***********************************************' 类名称:ChinaDay' 用途:' 根据输入的日期计算该日期的农历天干地支及当年属相' 使用方法:' 第一个参数为输入参数,不填写默认为当日,' 只计算1921-2-8之后的日期' ##-------------------------------------------##' Dim objChinaDay' Dim sDay, sWeekDay, sChinaDay, sChinaYear,sChinaAni' Set objChinaDay = New ChinaDay' Call objChinaDay.Action("",sDay,sWeekDay,sChinaYear,sChinaDay,sChinaAni)' Response.Write sDay&amp;"&lt;BR&gt;"' Response.Write sWeekDay&amp;"&lt;BR&gt;"' Response.Write sChinaYear&amp;"&lt;BR&gt;"' Response.Write sChinaDay&amp;"&lt;BR&gt;"' Response.Write sChinaAni&amp;"&lt;BR&gt;"'*******************************************************Class ChinaDayDim arrWeekName(7), MonthAdd(11), NongliData(99)Dim arrTianGan(9), arrDiZhi(11), arrShuXiang(11), arrDayName(30), arrMonName(12) Dim curTime, curYear, curMonth, curDay, curWeekdayDim i, m, n, k, isEnd, bit, TheDate'初始化数据Sub Class_Initialize()'---------------------------------------------------'定义显示字串'星期名arrWeekName(0) = "*"arrWeekName(1) = "星期日"arrWeekName(2) = "星期一"arrWeekName(3) = "星期二"arrWeekName(4) = "星期三"arrWeekName(5) = "星期四"arrWeekName(6) = "星期五"arrWeekName(7) = "星期六"'天干名称arrTianGan(0) = "甲"arrTianGan(1) = "乙"arrTianGan(2) = "丙"arrTianGan(3) = "丁" arrTianGan(4) = "戊" arrTianGan(5) = "己" arrTianGan(6) = "庚" arrTianGan(7) = "辛" arrTianGan(8) = "壬" arrTianGan(9) = "癸"'地支名称arrDiZhi(0) = "子" arrDiZhi(1) = "丑" arrDiZhi(2) = "寅" arrDiZhi(3) = "卯" arrDiZhi(4) = "辰" arrDiZhi(5) = "巳" arrDiZhi(6) = "午" arrDiZhi(7) = "未" arrDiZhi(8) = "申" arrDiZhi(9) = "酉" arrDiZhi(10) = "戌" arrDiZhi(11) = "亥"'属相名称arrShuXiang(0) = "鼠" arrShuXiang(1) = "牛" arrShuXiang(2) = "虎" arrShuXiang(3) = "兔" arrShuXiang(4) = "龙" arrShuXiang(5) = "蛇" arrShuXiang(6) = "马" arrShuXiang(7) = "羊" arrShuXiang(8) = "猴" arrShuXiang(9) = "鸡" arrShuXiang(10) = "狗" arrShuXiang(11) = "猪" '农历日期名arrDayName(0) = "*" arrDayName(1) = "初一" arrDayName(2) = "初二" arrDayName(3) = "初三" arrDayName(4) = "初四" arrDayName(5) = "初五" arrDayName(6) = "初六" arrDayName(7) = "初七" arrDayName(8) = "初八" arrDayName(9) = "初九"arrDayName(10) = "初十"arrDayName(11) = "十一"arrDayName(12) = "十二"arrDayName(13) = "十三"arrDayName(14) = "十四"arrDayName(15) = "十五"arrDayName(16) = "十六"arrDayName(17) = "十七"arrDayName(18) = "十八"arrDayName(19) = "十九"arrDayName(20) = "二十"arrDayName(21) = "廿一"arrDayName(22) = "廿二"arrDayName(23) = "廿三"arrDayName(24) = "廿四"arrDayName(25) = "廿五"arrDayName(26) = "廿六"arrDayName(27) = "廿七"arrDayName(28) = "廿八"arrDayName(29) = "廿九"arrDayName(30) = "三十"'农历月份名arrMonName(0) = "*"arrMonName(1) = "正"arrMonName(2) = "二"arrMonName(3) = "三"arrMonName(4) = "四"arrMonName(5) = "五"arrMonName(6) = "六"arrMonName(7) = "七"arrMonName(8) = "八"arrMonName(9) = "九"arrMonName(10) = "十"arrMonName(11) = "十一"arrMonName(12) = "腊"'--------------------------------------------------------- '公差数据定义'公历每月前面的天数MonthAdd(0) = 0MonthAdd(1) = 31MonthAdd(2) = 59MonthAdd(3) = 90MonthAdd(4) = 120MonthAdd(5) = 151MonthAdd(7) = 212 MonthAdd(8) = 243 MonthAdd(9) = 273 MonthAdd(10) = 304 MonthAdd(11) = 334'农历数据NongliData(0) = 2635 NongliData(1) = 333387 NongliData(2) = 1701 NongliData(3) = 1748 NongliData(4) = 267701 NongliData(5) = 694 NongliData(6) = 2391 NongliData(7) = 133423 NongliData(8) = 1175 NongliData(9) = 396438 NongliData(10) = 3402 NongliData(11) = 3749 NongliData(12) = 331177 NongliData(13) = 1453 NongliData(14) = 694 NongliData(15) = 201326 NongliData(16) = 2350 NongliData(17) = 465197 NongliData(18) = 3221 NongliData(19) = 3402 NongliData(20) = 400202 NongliData(21) = 2901 NongliData(22) = 1386 NongliData(23) = 267611 NongliData(24) = 605 NongliData(25) = 2349 NongliData(26) = 137515 NongliData(27) = 2709 NongliData(28) = 464533 NongliData(29) = 1738 NongliData(30) = 2901 NongliData(31) = 330421 NongliData(32) = 1242 NongliData(33) = 2651 NongliData(34) = 199255 NongliData(35) = 1323 NongliData(36) = 529706NongliData(38) = 1706 NongliData(39) = 398762 NongliData(40) = 2741 NongliData(41) = 1206 NongliData(42) = 267438 NongliData(43) = 2647 NongliData(44) = 1318 NongliData(45) = 204070 NongliData(46) = 3477 NongliData(47) = 461653 NongliData(48) = 1386 NongliData(49) = 2413 NongliData(50) = 330077 NongliData(51) = 1197 NongliData(52) = 2637 NongliData(53) = 268877 NongliData(54) = 3365 NongliData(55) = 531109 NongliData(56) = 2900 NongliData(57) = 2922 NongliData(58) = 398042 NongliData(59) = 2395 NongliData(60) = 1179 NongliData(61) = 267415 NongliData(62) = 2635 NongliData(63) = 661067 NongliData(64) = 1701 NongliData(65) = 1748 NongliData(66) = 398772 NongliData(67) = 2742 NongliData(68) = 2391 NongliData(69) = 330031 NongliData(70) = 1175 NongliData(71) = 1611 NongliData(72) = 200010 NongliData(73) = 3749 NongliData(74) = 527717 NongliData(75) = 1452 NongliData(76) = 2742 NongliData(77) = 332397 NongliData(78) = 2350 NongliData(79) = 3222 NongliData(80) = 268949NongliData(82) = 3493NongliData(83) = 133973NongliData(84) = 1386NongliData(85) = 464219NongliData(86) = 605NongliData(87) = 2349NongliData(88) = 334123NongliData(89) = 2709NongliData(90) = 2890NongliData(91) = 267946NongliData(92) = 2773NongliData(93) = 592565NongliData(94) = 1210NongliData(95) = 2651NongliData(96) = 395863NongliData(97) = 1323NongliData(98) = 2707NongliData(99) = 265877End Sub'############################################################'主要方法Action' inDay 输入日期,如果不输入则默认为当前日期' sDay 中文格式日期' sWeekDay 周几' sChinaYear 农历年' sChinaDay 农历日' sChinaAni 属相'############################################################ Public Function Action(inDay,sDay,sWeekDay,sChinaYear,sChinaDay,sChinaAni) '转换要转换的日期If inDay="" Or Not IsDate(inDay) Then'获取当前系统时间curTime = Now()ElsecurTime = CDate(inDay)End IfIf Datediff("d",curTime,Cdate("1921-2-8"))&gt;0 ThenExit FunctionEnd If'生成当前公历年、月、日==&gt; sDaycurYear = Year(curTime)curMonth = Month(curTime)curDay = Day(curTime)sDay = curYear&amp;"年"If (curMonth &lt; 10) ThensDay = sDay&amp;"0"&amp;curMonth&amp;"月"ElsesDay = sDay&amp;curMonth&amp;"月"End IfIf (curDay &lt; 10) ThensDay = sDay&amp;"0"&amp;curDay&amp;"日"ElsesDay = sDay&amp;curDay&amp;"日"End If'生成当前公历星期==&gt; sWeekDaycurWeekday = Weekday(curTime)sWeekDay = arrWeekName(curWeekday)'计算到初始时间1921年2月8日的天数:1921-2-8(正月初一)TheDate = (curYear - 1921) * 365 + Int((curYear - 1921) / 4) + curDay + MonthAdd(curMonth - 1) - 38If ((curYear Mod 4) = 0 AND curMonth &gt; 2) ThenTheDate = TheDate + 1End If'计算农历天干、地支、月、日isEnd = 0m = 0'------------------------------------DoIf (NongliData(m) &lt; 4095) Thenk = 11Elsek = 12End ifn = k'------------------------------------DoIf (n &lt; 0) ThenExit DoEnd If'获取NongliData(m)的第n个二进制位的值bit = NongliData(m)For i = 1 To n Step 1bit = Int(bit / 2)Nextbit = bit Mod 2If (TheDate &lt;= 29 + bit) ThenisEnd = 1Exit DoEnd IfTheDate = TheDate - 29 - bitn = n - 1Loop'------------------------------------If (isEnd = 1) ThenExit DoEnd Ifm = m + 1Loop'------------------------------------curYear = 1921 + mcurMonth = k - n + 1curDay = TheDateIf (k = 12) ThenIf (curMonth = (Int(NongliData(m) / 65536) + 1)) ThencurMonth = 1 - curMonthElseIf (curMonth &gt; (Int(NongliData(m) / 65536) + 1)) ThencurMonth = curMonth - 1End ifEnd If'生成农历天干、地支==&gt; sChinaYearsChinaYear = "农历"&amp;arrTianGan(((curYear - 4) Mod 60) Mod 10)&amp;arrDiZhi(((curYear - 4) Mod 60) Mod 12)&amp;"年"'生成属相== &gt; sChinaAnisChinaAni = arrShuXiang(((curYear - 4) Mod 60) Mod 12)'生成农历月、日==&gt; NongliDayStrIf (curMonth &lt; 1) ThensChinaDay = "闰"&amp;arrMonName(-1 * curMonth)ElsesChinaDay = arrMonName(curMonth)End IfsChinaDay = sChinaDay&amp;"月"sChinaDay = sChinaDay &amp; arrDayName(curDay)End FunctionEnd Class%&gt;&lt;%Dim objChinaDayDim sDay, sWeekDay, sChinaDay, sChinaYear,sChinaAniSet objChinaDay = New ChinaDayCall objChinaDay.Action(request("data"),sDay,sWeekDay,sChinaYear,sChinaDay,sChinaAni)Set objChinaDay = Nothing'Response.Write sDay&amp;"&lt;BR&gt;"'Response.Write sWeekDay&amp;"&lt;BR&gt;"'Response.Write sChinaYear&amp;"&lt;BR&gt;"'Response.Write sChinaDay&amp;"&lt;BR&gt;"'Response.Write sChinaAni&amp;"&lt;BR&gt;"%&gt;&lt;html&gt;&lt;head&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"&gt;&lt;title&gt;农历日历&lt;/title&gt;&lt;style&gt;.itm {font-family: 宋体; font-size: 14px;}.chn {font-family: 宋体; font-size: 12px}.chnred {font-family: 宋体; color: #FF0000; font-size: 12px}.chnblue {font-family: 宋体; color: #0000FF; font-size: 12px}&lt;/style&gt;&lt;/head&gt;&lt;body bgcolor="#FFFFFF"&gt;&lt;!--显示站点日历--&gt;&lt;%=sDay%&gt; &lt;%=sWeekDay%&gt; &lt;%=sChinaYear &amp; "(" &amp; sChinaAni &amp; ")"%&gt; &lt;%=sChinaDay%&gt;&lt;form action="?" method="post"&gt;请输入日期:&lt;input type="text" name="data"&gt;&lt;font color="#FF0000"&gt;例如:2006-8-5&lt;/font&gt;&lt;br/&gt;&lt;input type="submit" value="提交"&gt;&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;更多信息请查看IT技术专栏。

显示网页当前时间代码六种

显示网页当前时间代码六种

显⽰⽹页当前时间代码六种第⼀种:###2013年5⽉10⽇ 12:05:08 星期三<div id="jnkc"></div><script>setInterval("jnkc.innerHTML=new Date().toLocaleString()+' 星期'+'⽇⼀⼆三四五六'.charAt(new Date().getDay());",1000);</script>第⼆种 :2013年5⽉10⽇<script language="JavaScript"><!--tmpDate = new Date();date = tmpDate.getDate();month= tmpDate.getMonth() + 1 ;year= tmpDate.getYear();document.write(year);document.write("年");document.write(month);document.write("⽉");document.write(date);document.write("⽇");// --></script>第三种###<!-- 时间代码开始 2013-11-11 星期⼏ --><SCRIPT language=JavaScript>today=new Date();function initArray(){this.length=initArray.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=initArray.arguments[i]}var d=new initArray("星期⽇","星期⼀","星期⼆","星期三","星期四","星期五","星期六");document.write("<font color=#0099ff> ",today.getYear(),"年",today.getMonth()+1,"⽉",today.getDate(),"⽇ ",d[today.getDay()+1],"</font>" ); </SCRIPT><!-- 时间代码结束 2013-11-11 星期⼏ -->第四种(兼容⽕狐)<script language="JavaScript" type="text/javascript"><!--var enabled = 0; today = new Date();var day; var date;if(today.getDay()==0) day = " 星期⽇"if(today.getDay()==1) day = " 星期⼀"if(today.getDay()==2) day = " 星期⼆"if(today.getDay()==3) day = " 星期三"if(today.getDay()==4) day = " 星期四"if(today.getDay()==5) day = " 星期五"if(today.getDay()==6) day = " 星期六"date = (today.getFullYear()) + "年" + (today.getMonth() + 1 ) + "⽉" + today.getDate() + "⽇" + day +""; document.write(date);// --></script>第五种<script language="JavaScript"><!--tmpDate = new Date();date = tmpDate.getDate();month= tmpDate.getMonth() + 1 ;year= tmpDate.getYear();document.write(year);document.write("年");document.write(month);document.write("⽉");document.write(date);document.write("⽇");// --></script>第六种<script language="JavaScript">var isMonth = newArray("1⽉","2⽉","3⽉","4⽉","5⽉","6⽉","7⽉","8⽉","9⽉","10⽉","11⽉","12⽉");var isDay = newArray("星期⽇","星期⼀","星期⼆","星期三","星期四","星期五","星期六","星期⽇");today = new Date () ;Year=today.getYear();Date=today.getDate();if (document.all)document.title="今天是: "+Year+"年"+isMonth[today.getMonth()]+Date+"⽇"+isDay[today.getDay()]</script>在IE标题栏显⽰⽇期时间的JS代码可以让时间、⽇期显⽰在你⽹页的标题栏,很个性的功能,其实代码很简单,看了就会,也很好调⽤。

netCalendar控件使用说明

netCalendar控件使用说明

netCalendar控件使用说明.netCalendar控件使用说明1、定义和用法、Calendar控件用于在浏览器中显示日历。

该控件可显示某个月的日历,允许用户选择日期,也可以跳到前一个或下一个月。

2、属性、属性CaptionCaptionAlignCellPaddingCellSpacingDayHeaderStyleDayNameFo rmatDayStyleFirtDayOfWeekNe某tMonthTe某tNe某tPrevFormatNe某tPrevStyleOtherMonthDayStylePrevMonthTe某trunat描述日历的标题。

日历标题文本的对齐方式。

单元格边框与内容之间的空白,以像素计。

单元格之间的空白,以像素计。

显示一周中某天的名称的样式。

显示周中各天的名称格式。

显示日期的样式。

哪天是周的第一天。

显示下一月链接的文本。

下一月和上一月链接的格式。

显示下一月和上一月链接的样式。

显示不在当前月中的日期的样式。

显示上一月链接的文本。

规定该控件是服务器控件。

必须设置为"erver"。

.NET2.02.01.01.01.01.01.01.01.01.01.01.01.01.0 SelectedDateSelectedDateSelectedDayStyleSelectionModeSelectM onthTe某tSelectorStyleSelectWeekTe某tShowDayHeaderShowGridLineShowNe某tPrevMonthShowTitleTitleFormatTitleStyleTodayDayStyleTodayDateUe AcceibleHeader选定的日期。

选定的日期。

选定日期的样式。

允许用户如何选择日期。

显示为月份选择链接的文本。

月份和周的选择链接的样式。

显示为周的选择链接的文本。

1.01.01.01.01.01.01.0布尔值,该值指示是否显示一周中各天的标头。

万年历代码c语言

万年历代码c语言

万年历代码c语言万年历是一种实用的日历工具,它可以根据年、月、日来显示当天的日期信息,并可以切换到其他日期来查询对应的日期信息。

在编写万年历的代码时,我们需要考虑输入的年份是否为闰年、每个月的天数、以及每个月第一天是星期几等等。

以下是一份使用C语言编写万年历的参考代码:```c#include <stdio.h>// 判断是否为闰年int isLeapYear(int year) {return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); }// 获取某年某月的天数int getMonthDays(int year, int month) {int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};if (month == 2 && isLeapYear(year)) {return 29;}return days[month - 1];}// 获取某年某月第一天是星期几int getFirstDayOfWeek(int year, int month) {int day = 1;for (int i = 1800; i < year; i++) {if (isLeapYear(i)) {day = (day + 366) % 7;} else {day = (day + 365) % 7;}}for (int i = 1; i < month; i++) {day = (day + getMonthDays(year, i)) % 7;}return day;}int main() {int year, month;printf("请输入年份:");scanf("%d", &year);printf("请输入月份:");scanf("%d", &month);// 判断输入是否合法if (year < 1800 || month < 1 || month > 12) {printf("输入的年份或月份不合法!\n");return 0;}// 获取某年某月的天数和第一天是星期几int days = getMonthDays(year, month);int firstDayOfWeek = getFirstDayOfWeek(year, month); // 打印万年历printf("日一二三四五六\n");for (int i = 0; i < firstDayOfWeek; i++) {printf(" ");}for (int i = 1; i <= days; i++) {printf("%2d ", i);if ((firstDayOfWeek + i) % 7 == 0) {printf("\n");}}printf("\n");return 0;}```以上代码实现了一个简单的万年历功能,在控制台输出给定年份和月份的月历。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

net显示今天农历的代码!
[csharp]using System;
using System.Globalization;//
namespace Project.ChinaDate
{
///
<summary>
/// 显示今天农历类
///
</summary>
public
class CNDate
{
private DateTime m_Date; //今天的日期
private
readonly
int cny; //农历的年月日
private
int cnm; //农历的年月日
private
readonly
int cnd; //农历的年月日
private
readonly
int icnm; //农历闰月
///
<summary>
/// 显示日期构造函数
///
</summary>
public CNDate()
{
m_Date = DateTime.Today;
ChineseLunisolarCalendar cnCalendar =
new ChineseLunisolarCalendar();
cny = cnCalendar.GetSexagenaryYear(m_Date);
cnm = cnCalendar.GetMonth(m_Date);
cnd = cnCalendar.GetDayOfMonth(m_Date);
icnm =
cnCalendar.GetLeapMonth(cnCalendar.GetYear(m_Date));
}
///
<summary>
/// 返回格式化的公历显示
///
</summary>
///
<returns>格式如:2008年05月14日</returns>
public
string GetDate()
{
int y = m_Date.Year;
int m = m_Date.Month;
int d = m_Date.Day;
return String.Format("{0}年{1:00}月{2:00}日", y, m, d); }
///
<summary>
/// 返回格式化的星期显示
///
</summary>
///
<returns>格式如:星期日</returns>
public
string GetWeek()
{
string ws =
"星期";
int w = Convert.ToInt32(m_Date.DayOfWeek);
ws = ws +
"日一二三四五六".Substring(w, 1);
return ws;
}
///
<summary>
/// 返回格式化的农历显示
///
</summary>
///
<returns>格式如:戊子(鼠)年润四月廿三</returns>
public
string GetCNDate()
{
string txcns =
"";
const
string szText1 =
"癸甲乙丙丁戊己庚辛壬";
const
string szText2 =
"亥子丑寅卯辰巳午未申酉戌";
const
string szText3 =
"猪鼠牛虎免龙蛇马羊猴鸡狗";
int tn = cny %
10; //天干
int dn = cny %
12; //地支
txcns += szText1.Substring(tn, 1);
txcns += szText2.Substring(dn, 1);
txcns +=
"("
+ szText3.Substring(dn, 1) +
")年";
//格式化月份显示
string[] cnMonth ={ "", "正月", "二月", "三月", "四月", "五月", "六月" , "七月", "八月", "九月", "十月", "十一月", "十二月", "十二月" };
if (icnm >
0)
{
for (int i = icnm +
1; i <
13; i++) cnMonth = cnMonth[i -
1];
cnMonth[icnm] =
"闰"
+ cnMonth[icnm];
}
txcns += cnMonth[cnm];
string[] cnDay ={ "", "初一", "初二", "初三", "初四", "初五", "初六", "初七"
, "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六"
, "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五"
, "廿六", "廿七", "廿八", "廿九", "三十" };
txcns += cnDay[cnd];
return txcns;
}
}[/csharp]。

相关文档
最新文档