導航:首頁 > 編程語言 > 月歷代碼

月歷代碼

發布時間: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>

閱讀全文

與月歷代碼相關的資料

熱點內容
電信網路怎麼繳費 瀏覽:423
杜文澤電影日本 瀏覽:312
看片群qq 瀏覽:516
法國愛情電影完整免費版 瀏覽:421
韓國電影一個女人的手被個被換了什麼電影 瀏覽:228
變身之後我與她的狂想曲下載 瀏覽:903
催眠科技晶元陳銀 瀏覽:332
求免費看片 瀏覽:910
蘋果a1534安裝win8 瀏覽:294
內地票房排行榜實時 瀏覽:760
1080p藍光電影網站 瀏覽:933
能免費觀看vip電視劇網址 瀏覽:149
微信小程序和原生app 瀏覽:114
主角有九個轉世記憶 瀏覽:528
操作小機器人格鬥動漫 瀏覽:803
西風緊的小說哪本最好 瀏覽:32
法國庄園電視劇 瀏覽:393
求一小電影網址 瀏覽:212
大數據的讀音是什麼 瀏覽:889

友情鏈接