- /**
- * 根据给定的日期得到该日期的相关信息
- *
- * @param dateObj:日期对象
- *
- * @return daysInYear:当前日期在今年中是第几天
- * @return weekInYear:当前日期所在今年是第几周
- * @return weekInMonth:当前日期在今年这个月份是第几周
- * @return weekStartDate:当前日期所在周的星期一的日期
- * @return weekEndDate:当前日期所在周的周日的日期
- */
- function DateToWeekFormat(dateObj)
- {
- var year = dateObj.getFullYear();
- var month = dateObj.getMonth();
- var date = dateObj.getDate();
- var day = dateObj.getDay();
- var hr = dateObj.getHours();
- var min = dateObj.getMinutes();
- var sec = dateObj.getSeconds();
- var daysInYear = Math.ceil((dateObj-new Date(year,0,0))/86400000);
- var weekInYear = Math.ceil((daysInYear+new Date(year,0,1).getDay())/7);
- var weekInMonth = Math.ceil((date+new Date(year,month,1).getDay())/7);
- var weekStartDate = new Date(dateObj-(dateObj.getDay()-1)*86400000);
- var weekEndDate =new Date((weekStartDate/1000+6*86400)*1000);
- return {daysInYear:daysInYear,weekInYear:weekInYear,weekInMonth:weekInMonth,weekStartDate:weekStartDate,weekEndDate:weekEndDate};
- }