代码改变世界

日历处理

2011-05-19 11:06  hanwesley  阅读(218)  评论(0编辑  收藏  举报

var date1 = "$!cpsGroupKeeperDO.beginTime";
            var date2 = "$!cpsGroupKeeperDO.endTime";
            var cf_enddate = Y.one("#cf_enddate");
            var cf_begindate = Y.one("#cf_begindate");
            if (cf_enddate)
                cf_enddate.set("value", date2);
            if (cf_begindate)
                cf_begindate.set("value",date1);

  var cal = new Y.doubleCalendar({
                startdb:{max_date:date2},//开始时间的控制,最小时间 ,最大时间 startdb:{from_date:"2010-06-10",max_date:"2010-06-10"}
                enddb:{max_date:new Date()},//结束时间的控制,最小时间 ,最大时间 enddb:{from_date:"2010-06-10",max_date:"2010-06-10"}
                bindstartinput: "#cf_begindate",
                bindendinput: "#cf_enddate",
                onsubmit: function(Y){
                    var begin = cf_begindate.get("value").parse_to_date();
                    var end = cf_enddate.get("value").parse_to_date();
                    if (begin < end) {
                        cf_enddate.set("value", end.parse_to_str());
                        Y.one(".J_double_calendar").setAttribute("enddate", begin.parse_to_str()).setContent(cf_begindate.get("value") + " 至 " + end.parse_to_str());
                    }
                }
            });