当前位置:编程学习 > JS >>

谁有js写的日历源码?

追问:帮帮忙了,我新手呀,要吃饭呀,可怜。
答案:
  //*******************Calendar Start ******************************//
/**
* 返回日期
* @param d the delimiter
* @param p the pattern of your date
* @author Xinge(修改)
*/
String.prototype.toDate = function(x, p) {
if(x == null) x = "-";
if(p == null) p = "dmy";
var a = this.split(x);
var y = parseInt(a[p.indexOf("y")]);
//remember to change this next century ;)
if(y.toString().length <= 2) y += 2000;
if(isNaN(y)) y = new Date().getFullYear();
var m = parseInt(a[p.indexOf("m")])-1;
var d = parseInt(a[p.indexOf("d")]);
if(isNaN(d)) d = 1;
return new Date(y, m, d);
}
/**
* 格式化日期
* @param d the delimiter
* @param p the pattern of your date
* @author Xinge(修改)
*/
Date.prototype.format = function(style) {
var o = {
"M+" : this.getMonth() + 1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"w+" : "天一二三四五六".charAt(this.getDay()), //week
"q+" : Math.floor((this.getMonth() + 3) / 3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(style)) {
style = style.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for(var k in o){
if(new RegExp("("+ k +")").test(style)){
style = style.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
}
}
return style;
};
/**
* 日历类
* @param beginYear 1990
* @param endYear ??
* @param lang ?(中文)|1(英语) 可自由扩充
* @param dateFormatStyle "yyyy-MM-dd";
* @version 2007-03-16
* @author Xinge(修改)
* @update
*/
function Calendar(lang,beginYear,endYear,dateFormatStyle) {
this.beginYear = 1990;
this.endYear = 2010;
this.lang = 1; //0(中文) | 1(英文)
this.dateFormatStyle = "dd-MM-yyyy";
if (beginYear != null && endYear != null){
this.beginYear = beginYear;
this.endYear = endYear;
}
什么要求的日历?
请访问: www.divandcss.com/main.asp

上一个:JS42级有什么任务
下一个:js高手来。2百分求助

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,