RSS
热门关键字:  java  Ajax  JSP  JSF  Struts
当前位置 : 首页>Java>列表

日历控件

来源: 作者: 时间:2007-09-18 点击:

*/
function returnDate()
{
if(WebCalendar.objExport)
{
var returnValue;
var a = WebCalendar.day[this.id.substr(8)].split("/");

if(WebCalendar.format == "yyyyMMdd" || WebCalendar.format == "yyyyMMddHHmmss")
//eos标准格式
{
returnValue = a[2] + appendZero(a[1]) + appendZero(a[0]);
if(WebCalendar.timeShow == true)
{
var h = WebCalendar.thisHour, m = WebCalendar.thisMinute, s = WebCalendar.thisSecond;
returnValue += appendZero(h) + appendZero(m) + appendZero(s);
}
}
else if(/^(y{4})(-|\/)(M{1,2})\2(d{1,2})$/.test(WebCalendar.format) ||
/^(y{4})(-|\/)(M{1,2})(-|\/)(d{1,2}) HH:mm:ss$/.test(WebCalendar.format))
//"-","/"间隔格式
{
var d;
if(/^(y{4})(-|\/)(M{1,2})\2(d{1,2})$/.test(WebCalendar.format))
d = WebCalendar.format.match(/^(\w{4})(-|\/)(\w{1,2})\2(\w{1,2})$/);
else
d = WebCalendar.format.match(/^(\w{4})(-|\/)(\w{1,2})\2(\w{1,2}) HH:mm:ss$/);
if(d==null)
{
alert("你设定的日期输出格式不对!\r\n\r\n请重新定义 WebCalendar.format !");
return false;
}
var flag = d[3].length==2 || d[4].length==2; //判断返回的日期格式是否要补零
returnValue = flag ? a[2] +d[2]+ appendZero(a[1]) +d[2]+ appendZero(a[0]) : a[2] +d[2]+ a[1] +d[2]+ a[0];
if(WebCalendar.timeShow == true)
{
var h = WebCalendar.thisHour, m = WebCalendar.thisMinute, s = WebCalendar.thisSecond;
returnValue += flag ? " "+ appendZero(h) +":"+ appendZero(m) +":"+ appendZero(s) : " "+ h +":"+ m +":"+ s;
}
}
else if(/^(y{4})(年)(M{1,2})(月)(d{1,2})(日)$/.test(WebCalendar.format) ||
/^(y{4})(年)(M{1,2})(月)(d{1,2})(日)(HH时mm分ss秒)$/.test(WebCalendar.format))
//中文格式
{
var d;
if(/^(y{4})(年)(M{1,2})(月)(d{1,2})(日)$/.test(WebCalendar.format))
d = WebCalendar.format.match(/^(y{4})(年)(M{1,2})(月)(d{1,2})(日)$/);
else
d = WebCalendar.format.match(/^(y{4})(年)(M{1,2})(月)(d{1,2})(日)(HH时mm分ss秒)$/);
if(d==null)
{
alert("你设定的日期输出格式不对!\r\n\r\n请重新定义 WebCalendar.format !");
return false;
}
var flag = d[3].length==2 || d[5].length==2; //判断返回的日期格式是否要补零
returnValue = flag ? a[2] + "年" + appendZero(a[1]) + "月" + appendZero(a[0]) + "日" : a[2] + "年" + a[1] + "月" + a[0] + "日";
if(WebCalendar.timeShow == true)
{
var h = WebCalendar.thisHour, m = WebCalendar.thisMinute, s = WebCalendar.thisSecond;
returnValue += flag ? appendZero(h) +"时"+ appendZero(m) + "分" + appendZero(s) + "秒" : h +"时"+ m + "分" + s + "秒";
}
}
else
//默认的返回格式
{
if(/^(y{4})(-)(M{1,2})\2(d{1,2}) HH:mm:ss$/.test(WebCalendar.format))
{
var h = WebCalendar.thisHour, m = WebCalendar.thisMinute, s = WebCalendar.thisSecond;
returnValue = a[2] + "-" + appendZero(a[1]) + "-" + appendZero(a[0]);
returnValue += " " + appendZero(h) +":"+ appendZero(m) + ":" + appendZero(s);
}
else
alert("你设定的日期输出格式不对!\r\n\r\n请重新定义 WebCalendar.format !");
}
WebCalendar.objExport.value = returnValue;
hiddenCalendar();
}
else
{
alert("你设定的日期输出位置不对!\r\n\r\n请重新定义 WebCalendar.objExport !");
}
}

function returnCurDate() //根据日期格式等返回当前日期
{
var yy = new Date().getFullYear(),mm = new Date().getMonth() +1,dd = new Date().getDate();
var h = new Date().getHours(), m = new Date().getMinutes(), s = new Date().getSeconds();
if(WebCalendar.objExport)
{
var returnValue;
if(WebCalendar.format == "yyyyMMdd" || WebCalendar.format == "yyyyMMddHHmmss")
//eos标准格式

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
Google Adsense
相关文章