导航:首页 > 编程语言 > 月历代码

月历代码

发布时间:2023-04-01 11:53:47

① 求日历的HTML代码...

网页台历代码如下:<html>
<head>
<title>网页上的日期台历</title>
<STYLE>
A.menuitem {
COLOR: menutext; TEXT-DECORATION: none
}
A.menuitem:hover {
COLOR: highlighttext; BACKGROUND-COLOR: highlight
}
DIV.contextmenu {
BORDER-RIGHT: 2px outset; BORDER-TOP: 2px outset; Z-INDEX: 999; VISIBILITY: hidden; BORDER-LEFT: 2px outset; BORDER-BOTTOM: 2px outset; POSITION: absolute; BACKGROUND-COLOR: buttonface
}
</STYLE>
</head>
<body>
<SCRIPT language=javaScript>
function Year_Month(){
var now = new Date();
var yy = now.getYear();
var mm = now.getMonth()+1;
var cl = '<font color="#0000df">';
if (now.getDay() == 0) cl = '迟州<font color="#c00000">'逗察;
if (now.getDay() == 6) cl = '<font color="#00c000">';
return(cl + yy + '年' + mm + '月</font>'); }
function Date_of_Today(){
var now = new Date();
var cl = '<font color="#ff0000">';
if (now.getDay() == 0) cl = '<font color="#c00000">';
if (now.getDay() == 6) cl = '<font color="#00c000">';
return(cl + now.getDate() + '</font>'); }
function Day_of_Today(){
var day = new Array();
day[0] = "星期日";
day[1] = "星期一";
day[2] = "星期二";
day[3] = "星期三";
day[4] = "星期四";
day[5] = "星期五";
day[6] = "星期六码指蔽";
var now = new Date();
///
var cl = '<font color="#0000df">';
if (now.getDay() == 0) cl = '<font color="#c00000">';
if (now.getDay() == 6) cl = '<font color="#00c000">';
return(cl + day[now.getDay()] + '</font>'); }
function CurentTime(){
var now = new Date();
var hh = now.getHours();
var mm = now.getMinutes();
var ss = now.getTime() % 60000;
ss = (ss - (ss % 1000)) / 1000;
var clock = hh+':';
if (mm < 10) clock += '0';
clock += mm+':';
if (ss < 10) clock += '0';
clock += ss;
return(clock); }
function refreshCalendarClock(){
document.all.calendarClock1.innerHTML = Year_Month();
document.all.calendarClock2.innerHTML = Date_of_Today();
document.all.calendarClock3.innerHTML = Day_of_Today();
document.all.calendarClock4.innerHTML = CurentTime(); }
var webUrl = webUrl;
document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td>');
document.write('<table id="CalendarClockFreeCode" border="0" cellpadding="0" cellspacing="0" width="60" height="70" ');
document.write('style="position:absolute;visibility:hidden" bgcolor="#eeeeee">');
document.write('<tr><td align="center"><font ');
document.write('style="cursor:hand;color:#ff0000;font-size:14pt;line-height:120%" ');
if (webUrl != 'netflower'){
document.write('</td></tr><tr><td align="center"><font ');
document.write('style="cursor:hand;color:#2000ff;font-size:9pt;line-height:110%" ');
}
document.write('</td></tr></table>');
document.write('<table border="0" cellpadding="0" cellspacing="0" width="61" bgcolor="#C0C0C0" height="70">');
document.write('<tr><td valign="top" width="100%" height="100%">');
document.write('<table border="1" cellpadding="0" cellspacing="0" width="58" bgcolor="#FEFEEF" height="67">');
document.write('<tr><td align="center" width="100%" height="100%" >');
document.write('<font id="calendarClock1" style="font-size:7pt;line-height:120%"></font><br>');
document.write('<font id="calendarClock2" style="color:#ff0000;font-family:Arial;font-size:14pt;line-height:120%"></font><br>');
document.write('<font id="calendarClock3" style="font-size:9pt;line-height:120%"></font><br>');
document.write('<font id="calendarClock4" style="color:#100080;font-size:8pt;line-height:120%"><b></b></font>');
document.write('</td></tr></table>');
document.write('</td></tr></table>');
document.write('</td></tr></table>');
setInterval('refreshCalendarClock()',1000);
</SCRIPT>
</body>
</html>

② C语言万年历代码

#include"stdio.h"
#include"stdlib.h"
main( )
{
int Year,Month; //年、月
int FirstDay_Year,FirstDay_Month; //某年的第一天是星期几,某年某月的第一天是星期几(范围是0~6,其中0代表星期日)
int IsLeapYear; //是否为闰年,0表示不是闰年,1表示是闰年
int i,d,y; //临时变量
char YN; //Yes No,程序是否要继续

int Days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//Days[1~12]存储每个月有多少天,其中二月的天数是可变的(闰年29天,平年28天),这里初始化为28天

printf(" C语言简单万年历\n"); //打印标题

XunHuan: //循环标号(可以通过goto跳转到这里)

printf("请输入年份<0000~9999>: "); //提示输入年份(0~9999)
scanf("%d",&Year); //把输入的年份赋值给变量Year

printf("请输入月份<0~12>: "); //提示输入月份(1~12)
scanf("%d",&Month); //把输入的月份赋值给变量Month

y=Year;
FirstDay_Year=5*(y/4)+(y%4)-(y/100)+(y/400);//蔡勒公式(计算某年的第一天是星期几)
IsLeapYear=(y%4==4&&y%100!=100||y%400==0)?1:0;
//判断是否为闰年
Days[2]=(IsLeapYear==1)?29:28; //闰年二月29天,非闰年二月28天
for(i=1,d=0;i<Month;i++)
d=d+Days[i];
FirstDay_Month=(d+FirstDay_Year)%7; //当月的第一天是星期几(0代表星期日)

printf("\n****************************************************\n");
printf("\t\t公元 %d 年 %2d 月",Year,Month); //打印年月
printf("\n****************************************************\n");

printf(" 星期日 星期一 星期二 星期三 星期四 星期五 星期六\n");
//打印星期表头
for(i=0;i<FirstDay_Month;i++)
printf("%7c",' '); //当某月的第一天不是星期日时打印空格占位

for(d=1;d<=Days[Month];d++) //循环,从每个月的第一天开始打印
{
printf("%7d",d);
if(((d+FirstDay_Month)%7)==0 && d<Days[Month])
printf("\n"); //当输出了星期六而且还未输出所有天数时,换行
}
printf("\n****************************************************\n");
printf("\n");
printf("是否继续(Y/N)?\n");
scanf("%c",&YN);
scanf("%c",&YN);
if(YN=='Y' || YN=='y')
goto XunHuan;
}

③ 日历代码

万年历代码:
<iframe
src="http://freefilehosting.net/file/?id=pdnxl6re"
width="509"
height=433
marginwidth="0"
marginheight="0"
hspace="0"
vspace="0"
frameborder="0"
scrolling="no"></iframe>
老黄历的源代码:
<IFRAME
style="BORDER-RIGHT:
#000000
1px
dotted;
BORDER-TOP:
#000000
1px
dotted;
BORDER-LEFT:
#000000
1px
dotted;
BORDER-BOTTOM:
#000000
1px
dotted"
border=0
name=nongli
marginHeight=0
src="http://www.nongli.com/todaylhl.htm"
frameBorder=no
width=149
scrolling=no
height=140></IFRAME>
最新日历代码(包括日历、星期、现在时纳纯间)
<IFRAME
border=0
name=www1.xise.cn
align=center
marginWidth=0
marginHeight=0
src="http://www1.xise.cn/rili/sj.htm"
frameBorder=0
width=146
scrolling=no
height=183></IFRAME>
代码一:<IFRAME
style="BORDER-RIGHT:
#000000
1px
dotted;
BORDER-TOP:
#000000
1px
dotted;
BORDER-LEFT:
#000000
1px
dotted;
BORDER-BOTTOM:
#000000
1px
dotted"
border=0
name=nongli
marginHeight=0
src="http://www.nongli.com/todaylhl.htm"
frameBorder=no
width=149
scrolling=no
height=140></IFRAME>
代码二:<iframe
name="jiro23"
src="http://astro.sina.com.cn/calendar1.htm"
width="500"
height="500"></iframe>
代码三:<iframe
scrolling=no
height=170
width=165
frameborder=0
marginHeight=0
marginWidth=0
src=http://home.id666.com/user/420009598/disk/webdisk/55.html></iframe>
具体步骤核茄枣是:复制代码---管理博客-----新增空白面板-----钩选显示源代码(出现钩号,同时文档里出现DIV的字样)----粘贴代码----钩选显示源代码(钩号消失)-----保存新增面板----定制个人首页----选取新增个人面板----保改拆存设置

④ 请问写一个日历的C语言程序,代码怎么写

#include<conio.h>
#include<stdio.h>
#include<time.h>
#include<stdlib.h>

constmonthDay[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
intisLeap(intyear)
{
if(year%4)return0;
if(year%400)return1;
if(year%100)return0;
return1;
}
intgetWeek(intyear,intmonth,intday)
{
intc,y,week;
if(month==1||month==2)//判断month是否为1或2
{
year--;
month+=12;
}
c=year/100;
y=year-c*100;
week=(c/4)-2*c+(y+y/4)+(13*(month+1)/5)+day-1;
while(week<0){week+=7;}
week%=7;
returnweek;
}

voiddisplay(intyear,intmonth)
{
intmonthDays,weekFirst,i;
monthDays=monthDay[month]+(month==2?isLeap(year):0);
weekFirst=getWeek(year,month,1);
system("cls");
printf("-------%4d年----%2d月------- ",year,month);
printf("星期日星期一星期二星期三星期四星期五星期六 ");
for(i=0;i<weekFirst;i++)printf("");
for(i=1;i<=monthDays;i++)
{
printf("%8d",i);
weekFirst++;
if(weekFirst>=7){printf(" ");weekFirst=0;}
}
}
voidmain()
{
intyear,month,chr;
time_ttimer;
structtm*tblock;
timer=time(NULL);
tblock=localtime(&timer);
year=tblock->tm_year+1900;
month=tblock->tm_mon+1;
while(1)
{
display(year,month);
chr=getch();
if(chr==0xe0)
{
chr=getch();
if(chr==0x4b)/*方向键(←)*/
{
month--;
if(month<1){month=12;year--;}
}
elseif(chr==0x4d)/*方向键(→)*/
{
month++;
if(month>12){month=1;year++;}
}
}
elseif(chr=='q'||chr=='Q')break;
}
}

苹果节假日日历代码

苹果节假日日历代码如下。
1、在浏览器上输入github.com,(可以在这先选翻译成简体中文)伏轿。
2、有账号的话直接登录,没账号的话注册一个账号。
3、注册后登录,然后在上面输入日历订阅。
4、然后会出现个页面,在下面直接复制代码。
5、打开日历,添加日历,添加订阅日悔运历,然后把第4步的代码复碧厅梁制上去就好了。

⑥ 用C语言怎么编写这个万年历

核心算法:星期(0~6)=(年份系数+月份系数+日期)%7;

其中,年份系数我以年做参照,已知2007年,年份系数是0,往前往后分别是递减和递增。增减规律:非闰年为±1,闰年1~2月-2或+1,闰年3~12月+2或者-1。

其中,12个月份系数对应:0,3,3,6,1,4,6,2,5,0,3,5。

根据以上规律,只要利用循环,就可以的到对应系数和星期。

日历实现翻页功能,按键盘左右方向键可以翻译查看当年其他月份,按向上方向键可以返回菜单。

下面是代码:

#include <stdio.h>

#include <malloc.h>

#include <string.h>

#include <conio.h>

#include <math.h>

#include <time.h>

#define XY 2007

#define X07 0//以2007年年系数0做参照

int isLeapYear(int year);//判断是否是闰年,是返回1,否返回0

int addyx(int yx,int n);//年系数自增,0~6,n:自增的跨度,返回自增后的年系数

int getYX(int year,int month);//获得年系数0~6

int getMX(int month);//获得月系数

int getWeek(int yx,int mx,int day);//通过年月系数(yx:年系数;mx:月系数)及日期获取星期

char *getStrWeek(int yx,int mx,int day);//通过年月系数(yx:年系数;mx:月系数)及日期获取星期对应的中文字符串

int getMaxDay(int year,int month);//通过年月获取当月最大天数

void prCalendar(int year,int month);//打印日历

int showMeun();//打印主菜单

int getDuration(int year,int month,int day);//通过日期获取距今天数

int calendar[6][7];

int main()

{

//int year,month,day,yx,mx;

while(1)

{

if(!showMeun())

break;

}

return 0;

}

int showMeun()//打印主菜单

{

int n,year,month,day,yx,mx;

while(1)

{

system("cls");

printf("1、输入年份,显示该年每个月的日历 ");

printf("2、输入年月,显示该月的天数 ");

printf("3、输入日期,显示距离今天的天数 ");

printf("4、输入日期,查询这一天是星期几 ");

printf("0、结束程序 ");

n=-1,year=0,month=0,day=0;

while(n<0 || n>4)

{

printf("请输入选择的菜单序号:");

scanf("%d",&n);

}

switch(n)

{

case 1:while(year<=0 || year>9999)

printf("请输入年份:"),scanf("%d",&year);

prCalendar(year,1);

break;

case 2:while(year<=0 || year>9999 || month<=0 || month>12)

printf("请输入年份及月份:"),scanf("%d%d",&year,&month);

printf("%4d年%2d月共有%d天 按任意键继续。。。。。。 ",year,month,getMaxDay(year,month)),getch();

break;

case 3:while(year<=0 || year>9999 || month<=0 || month>12 || day<0 || day>getMaxDay(year,month))

printf("请输入日期:"),scanf("%d%d%d",&year,&month,&day);

printf("距离今日有%d天 按任意键继续。。。。。。 ",getDuration(year,month,day)),getch();

break;

case 4:while(year<=0 || year>9999 || month<=0 || month>12 || day<0 || day>getMaxDay(year,month))

printf("请输入日期:"),scanf("%d%d%d",&year,&month,&day);

yx=getYX(year,month);

mx=getMX(month);

printf("%4d年%2d月%2d日是%s 按任意键继续。。。。。。 ",year,month,day,getStrWeek(yx,mx,day)),getch();

break;

case 0:return 0;

}

}

return n;

}

void prCalendar(int year,int month)//打印日历

{

char c1,c2;

int i,j,*p=NULL,yx,mx,cnt,w,maxDay;

while(1)

{

p=&calendar[0][0];

yx=getYX(year,month),mx=getMX(month);

cnt=0,w=getWeek(yx,mx,1);

maxDay=getMaxDay(year,month);

for(i=0;i<6;i++)

for(j=0;j<7;j++)

{

if(cnt<w)

p++,cnt++;

calendar[i][j]=0;

}

for(i=1;i<=maxDay;i++)

*p=i,p++;

system("cls");

printf(" %4d 年%2d月 ",year,month);

printf("日 一 二 三 四 五 六 ");

for(i=0;i<6;i++,printf(" "))

for(j=0;j<7;j++)

if(calendar[i][j]==0)

printf(" ");

else

printf("%2d ",calendar[i][j]);

printf("<- 按方向键向左或向右翻页 -> ");

printf(" 按向上方向键返回主菜单 ");

c1=getch();

c2=getch();

if(c1==-32 && c2==75)//左键

{

if(month==1)

month=12;

else

month--;

}

if(c1==-32 && c2==77)//右键

{

if(month==12)

month=1;

else

month++;

}

if(c1==-32 && c2==72)//上键

{

showMeun();

break;

}

}

}

int getDuration(int year,int month,int day)//通过日期获取距今天数

{

int i,y,m,d,sum=0,sum2=0,minY,maxY,minM,maxM,minD,maxD;

time_t tt;

struct tm *tmp;

time(&tt);

tmp=localtime(&tt);

y=1900+tmp->tm_year,m=1+tmp->tm_mon,d=tmp->tm_mday;//获取当前日期的年月日

if(year<y)

minY=year,maxY=y,minM=month,maxM=m,minD=day,maxD=d;

if(year>y)

minY=y,maxY=year,minM=m,maxM=month,minD=d,maxD=day;

if(year!=y)

{

for(i=minY;i<maxY;i++)//按相差年份累加(不包含右端最大年份)

if(isLeapYear(i))

sum+=366;//闰年

else

sum+=365;

for(i=1;i<minM;i++)//扣除左端年份已过月份对应天数

sum-=getMaxDay(minY,i);

sum-=minD;//扣除左端当月已过天数

for(i=1;i<maxM;i++)//累加右端最大年份已过月份对应天数(不包含最大年份当月)

sum+=getMaxDay(maxY,i);

sum+=maxD;//累加右端当月已过天数

}

else//如果年份相同,累加两边一年内已过天数,求差值

{

for(i=1;i<month;i++)

sum+=getMaxDay(month,i);

sum+=day;

for(i=1;i<m;i++)

sum2+=getMaxDay(m,i);

sum2+=d;

return abs(sum2-sum);

}

return sum;

}

int getMaxDay(int year,int month)//通过年月获取当月最大天数

{

int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};

if(isLeapYear(year) && month==2)

return days[month-1]+1;

return days[month-1];

}

char *getStrWeek(int yx,int mx,int day)//通过年月系数(yx:年系数;mx:月系数)及日期获取星期对应的中文字符串

{

int w;

static char week[7];

memset(week,0,7);

strcpy(week,"星期");

w=getWeek(yx,mx,day);

switch(w)

{

case 0:strcat(week,"日");break;

case 1:strcat(week,"一");break;

case 2:strcat(week,"二");break;

case 3:strcat(week,"三");break;

case 4:strcat(week,"四");break;

case 5:strcat(week,"五");break;

case 6:strcat(week,"六");break;

}

return week;

}

int getWeek(int yx,int mx,int day)//通过年月系数(yx:年系数;mx:月系数)及日期获取星期对应的数值0~6

{

return (yx+mx+day)%7;

}

int getMX(int month)//获得月系数

{

int xmonth[12]={0,3,3,6,1,4,6,2,5,0,3,5};//月系数:1-12月,每月的系数。

return xmonth[month-1];

}

int getYX(int year,int month)//获得年系数0~6

{

int yx=0,nyear=XY,isly,flag;

if(nyear==year)

return 0;

if(nyear<year)

flag=0,nyear++;

else

flag=1,nyear--;

while(1)

{

isly=isLeapYear(nyear);

if(!isly){//非闰年年系数累加1

if(!flag)

yx=addyx(yx,1);

else

yx=addyx(yx,-1);

}

if(isly && month>=1 && month<=2){//闰年1~2月年系数累加1,3`12月年系数累加2

if(!flag)

yx=addyx(yx,1);

else

yx=addyx(yx,-2);

}

else if(isly && month>=3 && month<=12){

if(!flag)

yx=addyx(yx,2);

else

yx=addyx(yx,-1);

}

if(nyear==year)

break;

if(!flag && nyear<year)

nyear++;

if(flag && nyear>year)

nyear--;

}

return yx;

}

int addyx(int yx,int n)//年系数自增,0~6,n:自增的跨度,返回自增后的年系数

{

if(n>0)

{

if(yx+n<=6)

return yx+n;

if(yx+n>6)

return yx+n-7;

}

if(n<0)

{

if(yx+n>=0)

return yx+n;

if(yx+n<0)

return yx+n+7;

}

return -1;

}

int isLeapYear(int year)//判断是否是闰年,是返回1,否返回0

{

if((year%4==0 && year%100!=0)||(year%400==0))

return 1;

return 0;

}

⑦ javascript html实现网页版日历代码

本文实例为大家分享了网页版日历代码,供大家参考,具体内容如下
效果图:
实现代码:
<html>
<head>
<link
rel="stylesheet"
type="text/css"
href="Skin.css">
<style>
<!--
table{
text-align:
center
}
-->
</style>
</head>
<body>
<div
align="center">
<script
language="javascript">
var
my
=
new
Date();
function
showc()
{
var
k=1;
var
j=1;
var
today;
var
tomonth;
var
theday=1;//日期
var
max;
var
temp;
var
tempday;//这个月第一天的星期
document.write
("<b>"
+
my.getFullYear()
+
"-"
+
(my.getMonth()+1)
+
"</b>");
document.write
("<table
border='1'
width='273'
height='158'>");
document.write
("<tr>");
document.write
("<td
height='23'
width='39'><font
color='red'>Sun</font></td>");
document.write
("<td
height='23'
width='39'>Mon</td>");
document.write
("<td
height='23'
width='39'>Tue</td>");
document.write
("<td
height='23'
width='39'>Wed</td>");
document.write
("<td
height='23'
width='39'>Thu</td>");
document.write
("<td
height='23'
width='39'>Fri</td>");
document.write
("<td
height='23'
width='39'>Sat</td>");
document.write
("</tr>");
temp=my.getDate();
my.setDate(1);
//document.write
(my.getDate());
tempday=my.getDay();//返回第一天是星期几
my.setDate(temp);
today=my.getDay();//返回现在星期几
switch
((my.getMonth()+1))
{
case
1:
case
3:
case
5:
case
7:
case
8:
case
10:
case
12:
max=31;
break;
case
4:
case
6:
case
9:
case
11:
max=30;
break;
default:
max=29;//这里没有考虑闰月!!
//document.write
(max);
}
for(k=0;k<6;k++)
{
document.write
("<tr>");
for(j=0;j<=6;j++)
{
document.write
("<td
height='23'
width='39'>");
if(j>=(tempday))
{
tempday=0;//设置为最小,相当于取消判断条件
if(theday<=max)
{
document.write
("<a
title="
+
my.getFullYear()
+
"-"
+
(my.getMonth()+1)
+
"-"
+theday
+
"
target='_blank'
href=detail.asp?date="
+
theday
+
">");
if(theday==my.getDate())
document.write
("<font
color='green'>["
+
theday
+
"]</font></a>");
else
if(j==0)
document.write
("<font
color='red'>"
+
theday
+
"</font></a>");
else
document.write
(theday
+
"</a>");
theday++;
}
}
document.write
("</td>");
}
document.write
("</tr>");
}
document.write
("</table>");
}
showc();
</script>
</div>
<body>
</html>
以上就是本文的全部内容,希望大家可以轻松实现网页版日历。

⑧ 求C语言编日历源代码的详细说明

/* 稍微改了下对齐格式,加了注释 */
/*
1、闰年的算法:
如果某年能被4整除但不能被100整除,
或者能被400整除,
则该年是闰年.
用表达式表示就是
(year %4 == 0 && year%100 != 0) || (year%400 == 0)

2、计算某一天是星期几:
已知1900年的1月1号为星期一,
然后就可以用某一天和1900年的1月1号相差的天数对7取余来求星期,
本题是用的公元1年的1月1号作为基准
*/
#include <stdio.h>
#include<conio.h>
#include<stdlib.h>
int IsLeapYear(int); //函数定义
void main()
{
int i;
int day;
int year;
int temp;
int temp_i;
long int Year_days = 0;
int Year_Start = 1;
int Per_Year_Days;
int month_day[]={31,28,31,30,31,30,31,31,30,31,30,31,29};

printf("Please enter the year: ");
scanf("%d",&year); //输入年份

while(Year_Start < year) //从公元1年开始执行while循环, 该年的一月一号为星期一
{
if( IsLeapYear( Year_Start ) )
Per_Year_Days = 366; //如果是闰年, 则一年有366天
else
Per_Year_Days = 365; //如果不是闰年, 则一年有365天

Year_days = Year_days + Per_Year_Days; //Year_days为从公元1年到输入年份的前一年的天数的总和
Year_Start++;
}

for( temp = 1; temp <=12; temp++ ) //temp从1到12, 对应一年内12个月
{
switch( temp ) //用switch语句将temp和12个月对应起来
{
case 1:
printf(" January(%d)\n",year); //一月
break;
case 2:
printf(" February(%d)\n",year); //二月
break;
case 3:
printf(" March(%d)\n",year); //三月
break;
case 4:
printf(" April(%d)\n",year); //四月
break;
case 5:
printf(" May(%d)\n",year); //五月
break;
case 6:
printf(" June(%d)\n",year); //六月
break;
case 7:
printf(" July(%d)\n",year); //七月
break;
case 8:
printf(" August(%d)\n",year); //八月
break;
case 9:
printf(" September(%d)\n",year); //九月
break;
case 10:
printf(" October(%d)\n",year); //十月
break;
case 11:
printf(" November(%d)\n",year); //十一月
break;
case 12:
printf(" December(%d)\n",year); //十二月
break;
}
i = Year_days % 7; //每个星期有7天, 故用每年的天数对7取余
printf("Mon\tTue\tWed\tThu\tFri\tSat\tSun\n");
if( i != 0 ) //如果余数不为零
for( temp_i = 0; temp_i < i; temp_i++)
printf("\t"); //则打印空格(这里用\t代替空格, 更加美观), 空格数为i
day = 1; //初始化day为1, 为下面的while循环做准备
if( IsLeapYear(year) && temp == 2) //如果输入的年份是闰年, 并且月份为2
while( day <= month_day[12] ) //day为一循环变量, 取值为1-365(闰年的话为1-366)
{
if( day >1 ) //如果天数大于一
if( Year_days % 7 == 0 ) //如果是星期日, 则换行
printf("\n");
if( day >= 10 )
printf("%d\t",day); //打印天数+空格
else
printf("%d\t",day);
Year_days++;
day++;
}

else //如果不满足"输入的年份是闰年, 并且月份为2"
while (day <= month_day[temp-1])
{
if( day > 1 )
if( Year_days % 7 == 0 )
printf("\n");
if( day >=10 )
printf("%d\t",day);
else
printf("%d\t",day);
Year_days++;
day++;
}
printf("\n");
if( getch() == 'q' ) //如果输入为q, 则退出程序
exit(0);
}
getch(); //每按一次键, 打印一个月份
}

int IsLeapYear( int year )
{
//判断是否是闰年, 是则返回1, 否则返回0
if ((year %4 == 0) && (year % 100 != 0) ||
(year % 400 == 0) )
return 1;
else
return 0;
}

⑨ 谁能给一段点击之后出现日历的代码

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftMargin="0" topMargin="0">
<script>
Seperator = "-";
var DateStr = "";
// value为指定格式的日期字符串
function SetDateFromCalendar(value)
{
if(top.frames.length>0)
{
top.frames("mainFrame").DateObjCtrl_SetDateValue(value);
}
else
{
parent.DateObjCtrl_SetDateValue(value);
}
DateStr = value;
}
// 返回日期字符串
function public_getSelectedDate()
{
return DateStr;
}
</script>
<script language="JavaScript">
var gdCtrl = new Object();
var gcGray = "#808080";
var gcToggle = "#ffff00";
var gcBG = "#cccccc";

var gdCurDate = new Date();
var giYear = gdCurDate.getFullYear();
var giMonth = gdCurDate.getMonth()+1;
var giDay = gdCurDate.getDate();
var VicPopCal = new Object();

// 显示日历控件
function fPopCalendar(popCtrl, dateCtrl, popCal){
parent.event.cancelBubble=true;
VicPopCal = popCal; // 弹出日历控件的ID
gdCtrl = dateCtrl; // 得到日期数字的控件销桥猜ID, popCtrl是指定日期控件出现位置的标识
fSetYearMon(giYear, giMonth);
var point = fGetXY(popCtrl); // 得到popCtrl的坐消薯标
with (VicPopCal.style) {
left = point.x;
top = point.y+popCtrl.offsetHeight+1; // 设置日历控件的坐标
visibility = 'visible';
}
VicPopCal.focus();
}
// 隐藏日历控件, 设置gdCtrl的值, 单击今天日期后执行该函数
// 直接得到日期字符串
function fSetDate(iYear, iMonth, iDay){
gdCtrl.value = iMonth+"-"+iDay+"-"+iYear; //Here, you could modify the locale as you need !!!!
VicPopCal.style.visibility = "hidden";
}
// 单击表格执行此函数
function fSetSelected(aCell){
var iOffset = 0;
var iYear = parseInt(tbSelYear.value);
var iMonth = parseInt(tbSelMonth.value);

aCell.bgColor = gcBG;
// 此段代码,控制要是点中的不是当月的日期,自动得到前一个月或后一个月
with (aCell.children["cellText"]){
var iDay = parseInt(innerText);
if (color==gcGray)
iOffset = (Victor<10)?-1:1;
iMonth += iOffset;
if (iMonth<1) {
iYear--;
iMonth = 12;
}else if (iMonth>12){
iYear++;
iMonth = 1;
}
}
// 获得年月日期数
var dateText = parseInt(aCell.innerText);
if(iMonth<亏型10)
iMonth = "0" + iMonth;
if(aCell.innerText<10)
dateText = "0" + dateText;
// 将年月日组成指定字符串传给回传函数
SetDateFromCalendar(iYear + Seperator + iMonth + Seperator + dateText);

}
// 指定当前object的显示位置
function Point(iX, iY){
this.x = iX;
this.y = iY;
}
// 建立当月的日期数组
function fBuildCal(iYear, iMonth) { // 传过来的月加了1,表示下一月
var aMonth=new Array();
for(i=1;i<7;i++)
aMonth[i]=new Array(i);
// 创建当前月第一天日期对象
var dCalDate=new Date(iYear, iMonth-1, 1);
var iDayOfFirst=dCalDate.getDay();//得到该日是星期几
var iDaysInMonth=new Date(iYear, iMonth, 0).getDate();// 得到下一月
var iOffsetLast=new Date(iYear, iMonth-1, 0).getDate()-iDayOfFirst+1;
var iDate = 1;
var iNext = 1;

for (d = 0; d < 7; d++)
aMonth[1][d] = (d<iDayOfFirst)?-(iOffsetLast+d):iDate++;
for (w = 2; w < 7; w++)
for (d = 0; d < 7; d++)
aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:-(iNext++);
return aMonth;
}
// 画出星期title,和显示数据
function fDrawCal(iYear, iMonth, iCellWidth, iDateTextSize) {
var WeekDay = new Array("日","一","二","三","四","五","六");
var styleTD = " bgcolor='"+gcBG+"' width='"+iCellWidth+"' bordercolor='"+gcBG+"' valign='middle' align='center' style='font:bold "+iDateTextSize+" Courier;";

with (document) {
write("<tr>");
for(i=0; i<7; i++)
write("<td "+styleTD+"color:#990099' >" + WeekDay[i] + "</td>");
write("</tr>");

for (w = 1; w < 7; w++) {
write("<tr>");
for (d = 0; d < 7; d++) {
write("<td id=calCell "+styleTD+"cursor:hand;' onMouseOver='this.bgColor=gcToggle' onMouseOut='this.bgColor=gcBG' onclick='fSetSelected(this)'>");
write("<font id=cellText Victor='KinLee'> </font>");
write("</td>")
}
write("</tr>");
}
}
}
// 填入表格日期数据,可用的和不可用的用不同的底色来区分
function fUpdateCal(iYear, iMonth) {
myMonth = fBuildCal(iYear, iMonth); // 初始化当月的日期显示数组
var i = 0;
for (w = 0; w < 6; w++)
for (d = 0; d < 7; d++)
with (cellText[(7*w)+d]) { // cellText是表格的标识,都叫cellText,用下标来指示
Victor = i++;
if (myMonth[w+1][d]<0) {
color = gcGray;
innerText = -myMonth[w+1][d];
}else{
color = ((d==0)||(d==6))?"red":"black"; // 星期六、日颜色为红色
innerText = myMonth[w+1][d];
}
}
}
// 在下拉框中选中当前年和月, 然后更新数据显示
function fSetYearMon(iYear, iMon){
tbSelMonth.options[iMon-1].selected = true;
for (i = 0; i < tbSelYear.length; i++)
if (tbSelYear.options[i].value == iYear)
tbSelYear.options[i].selected = true;
fUpdateCal(iYear, iMon);
}
// 上一月
function fPrevMonth(){
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;

if (--iMon<1) {
iMon = 12;
iYear--;
}

fSetYearMon(iYear, iMon);
}
// 下一月
function fNextMonth(){
var iMon = tbSelMonth.value;
var iYear = tbSelYear.value;

if (++iMon>12) {
iMon = 1;
iYear++;
}

fSetYearMon(iYear, iMon);
}

function fGetXY(aTag){
var oTmp = aTag;
var pt = new Point(0,0);
do {
pt.x += oTmp.offsetLeft;
pt.y += oTmp.offsetTop;
oTmp = oTmp.offsetParent;
} while(oTmp.tagName!="BODY");
return pt;
}

var gMonths = new Array("01","02","03","04","05","06","07","08","09","10","11","12");
//打印出年月日的显示的表格,之后再填入数字
with (document) {
write("<table id='popTable' border='0' bgcolor='#6699cc'>");
write("<TR>");
write("<td valign='middle' align='center'><input type='button' name='PrevMonth' value='<' style='height:20;width:20;FONT:16 Fixedsys' onClick='fPrevMonth()'>");
write(" <SELECT name='tbSelYear' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' Victor='Won'>");
for(i=2000;i<3000;i++)
write("<OPTION value='"+i+"'>"+i+"</OPTION>");
write("</SELECT>");
write(" <select name='tbSelMonth' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' Victor='Won'>");
for (i=0; i<12; i++)
write("<option value='"+(i+1)+"'>"+gMonths[i]+"</option>");
write("</SELECT>");
write(" <input type='button' name='NextMonth' value='>' style='height:20;width:20;FONT:16 Fixedsys' onclick='fNextMonth()'>");
write("</td>");
write("</TR><TR>");
write("<td align='center'>");
write("<DIV style='background-color:teal;'><table width='100%' border='0' cellpadding='2'>");
fDrawCal(giYear, giMonth, 19, 12);
write("</table></DIV>");
write("</td>");
write("</TR><TR><TD align='center'>");
write("<font style='cursor:hand;font:12 Fixedsys' onclick='fSetDate(giYear,giMonth,giDay)' onMouseOver='this.style.color=gcToggle' onMouseOut='this.style.color=0'>今天是: "+giYear+"年"+gMonths[giMonth-1]+"月"+giDay+"日"+"</font>");
write("</TD></TR>");write("</TD></TR>");
write("</TABLE>");
}

var today = new Date();
// 用当前的日期更新月历显示
fSetYearMon(today.getFullYear(), today.getMonth() + 1);
// 填入表格日期数据,可用的和不可用的用不同的底色来区分
//fUpdateCal(today.getFullYear(), today.getMonth() + 1);

</script>

</body>
</html>

⑩ ASP+JS日历源代码

直接保存成 asp文件 运行就可以
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="http://purl.org/dc" rel="schema.DC" />
<title>日历</title
</head>
<body bgcolor="#FFFFFF">
<%
' 要调用的函数声明
'根据年份及月份得到每月的总天数
Function GetDaysInMonth(iMonth, iYear)
Select Case iMonth
Case 1, 3, 5, 7, 8, 10, 12
GetDaysInMonth = 31
Case 4, 6, 9, 11
GetDaysInMonth = 30
Case 2
If IsDate("February 29, " & iYear) Then
GetDaysInMonth = 29
Else
GetDaysInMonth = 28
End If
End Select
End Function
'得到一个月开始的日期.
Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
Dim dTemp
dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1), dAnyDayInTheMonth)
GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function
'得到当前一个月的上一个月.
Function SubtractOneMonth(dDate)
SubtractOneMonth = DateAdd("m", -1, dDate)
End Function
'得到当前一个月的下一个月.
Function AddOneMonth(dDate)
AddOneMonth = DateAdd("m", 1, dDate)
End Function
' 函数声明结束

Dim dDate ' 日历显示的日期
Dim iDOW ' 每一月开始的日期
Dim iCurrent ' 当前日期
Dim iPosition ' 表格中的当前位置

' 得到选择的日期并检查日期的合法性
If IsDate(Request.QueryString("date")) Then
dDate = CDate(Request.QueryString("date"))
Else
If IsDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year")) Then
dDate = CDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year"))
Else
dDate = Date()

If Len(Request.QueryString("month")) <> 0 Or Len(Request.QueryString("day")) <> 0 Or Len(Request.QueryString("year")) <> 0 Or Len(Request.QueryString("date")) <> 0 Then
Response.Write "您所选择的日期格式不正确,系统会使用当前日期.<BR><BR>"
End If

End If
End If

'得到日期后我们先得到这个月的天数及这个月的起始日期.
iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)

%>
<table width="180" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><table width="150" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="5"> </td>
</tr>
</table>
<table width="180" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" colspan="7"><table border="0" cellpadding="0" cellspacing="0"width="100%">
<tr>
<td height="22" align="right"><a href="rl.asp?date=<%= SubtractOneMonth(dDate) %>"><img src="../images/dot_left.gif" width="15" height="14" border="0" /></a></td>
<td align="center"><font color="999999"><b><%= MonthName(Month(dDate)) & " " & Year(dDate) %></b></font></td>
<td><a href="rl.asp?date=<%= AddOneMonth(dDate) %>"><img src="../images/dot_right.gif" width="15" height="14" border="0" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td width="25" height="22" align="center"><font
color="d08c00"><b>日</b></font> </td>
<td width="25" align="center"><b><font color="999999">一</font></b> </td>
<td width="25" align="center"><b><font color="999999">二</font></b> </td>
<td width="25" align="center"><b><font color="999999">三</font></b> </td>
<td width="25" align="center"><b><font color="999999">四</font></b> </td>
<td width="25" align="center"><b><font color="999999">五</font></b> </td>
<td width="25" align="center"><b><font color="d08c00">六</font></b> </td>
</tr>
<%
' 如果这个月的起始日期不是周日的话就加空的单元.
If iDOW <> 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
iPosition = 1
Do While iPosition < iDOW
Response.Write vbTab & vbTab & "<TD></TD>" & vbCrLf
iPosition = iPosition + 1
Loop
End If

' 绘制这个月的日历
iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM
' 如果是一行的开头就使用 TR 标记
If iPosition = 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
End If

' 如果这一天是我们选择的日期就高亮度显示该日期.
If iCurrent = Day(dDate) Then
Response.Write vbTab & vbTab & "<TD BGCOLOR=#eeeeee height=18 align=center><B>" & iCurrent & "</B></TD>" & vbCrLf
Else
Response.Write vbTab & vbTab & "<TD height=18 align=center><A HREF=""./rl.asp?date=" & Month(dDate) & "-" & iCurrent & "-" & Year(dDate) & """>" & iCurrent & "</A></TD>" & vbCrLf
End If

' 如果满一周的话表格就另起一行
If iPosition = 7 Then
Response.Write vbTab & "</TR>" & vbCrLf
iPosition = 0
End If

iCurrent = iCurrent + 1
iPosition = iPosition + 1
Loop

' 如果一个月不是以周六结束则加上相应的空单元.
If iPosition <> 1 Then
Do While iPosition <= 7
Response.Write vbTab & vbTab & "<TD></TD>" & vbCrLf
iPosition = iPosition + 1
Loop
Response.Write vbTab & "</TR>" & vbCrLf
End If
%>
</table>
<table width="150" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="5"> </td>
</tr>
</table></td>
</tr>
</table>

阅读全文

与月历代码相关的资料

热点内容
文件币软件 浏览:61
创意编程用到了哪些知识 浏览:303
文件字体可以缩小多少 浏览:922
数据仓库什么意思 浏览:12
在手机上编程能干什么 浏览:564
有色听书 浏览:229
金融数据领域大数据 浏览:551
两台win7电脑怎么传文件 浏览:946
检测iphone触屏灵敏度 浏览:838
安捷通网络技术有限公司 浏览:708
mvc怎么发布网站 浏览:275
枪版电影网电影驿站 浏览:322
港版《武则天》电影 浏览:259
大伟二娃三棱四猴什么电影 浏览:27
win10重置会删游戏 浏览:585
哪些不属于linux文件系统 浏览:326
宝马frm数据修复是什么用 浏览:57
文件放进u盘然后打不开 浏览:861
哪些城市小学开编程课 浏览:550
被窝电影0855影院 浏览:793

友情链接