nodejs 周操作
来源:互联网 发布:淘宝特价 编辑:程序博客网 时间:2024/06/03 23:00
var Rangedate = require('rangedate');Date.prototype.normalize = function () { return this.toLocaleDateString() + " 00:00:00";};Date.prototype.otherDay = function (day) { return new Date(this.getFullYear(), this.getMonth(), this.getDate() + day, this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds());};Date.prototype.durationDay = function (day) { var s = new Date(this.normalize()); return Rangedate(s, day).map(function (data) { return new Date(data.normalize()); });};function getMondayByToday(today) { var _weekDay = today.getDay();//0,1,2,3,4,5,6 _weekDay = (_weekDay == 0) ? (7) : _weekDay; var mondayDateThisWeek = today.otherDay(-(_weekDay - 1)); return mondayDateThisWeek;}function getWeekDurationDayPoolByToday(today) { var monday = getMondayByToday(today); var sunday = monday.otherDay(6); var weekPool = monday.durationDay(sunday); return weekPool;}function theWeekOfYear(curDate) { /* date1是当前日期 date2是当年第一天 d是当前日期是今年第多少天 用d + 当前年的第一天的周差距的和在除以7就是本年第几周 */ var a = curDate.getFullYear(); var b = curDate.getMonth() + 1; var c = curDate.getDate(); var date1 = new Date(a, parseInt(b) - 1, c), date2 = new Date(a, 0, 1), d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000); return Math.ceil( (d + ((date2.getDay() + 1) - 1)) / 7);}var weekPool = getWeekDurationDayPoolByToday(new Date());console.log("weekPool:",weekPool);console.log(theWeekOfYear(new Date("2016-2-1")))
1 0
- nodejs 周操作
- nodejs - mysql操作示例
- nodejs - redis操作例程
- nodejs+mongoskin操作mongo
- nodejs操作mongodb
- nodejs文件操作
- nodejs文件操作
- nodejs 文件操作笔记
- nodejs之文件操作
- Nodejs mongoose操作mongodb
- nodejs直接操作mongodb
- Nodejs 操作redis数据库
- Nodejs 操作mysql数据库
- nodejs 操作redis
- NodeJs文件操作备注
- NodeJS 基本操作
- [nodejs] cookie操作
- nodejs sqlite 数据库操作
- HTML文本框readonly和disabled属性的区别
- 模板
- node.js 学习记录(一)安装
- POJ 3254 Corn Fields 状态压缩dp 查找情况数
- ASP.Net WebAPI的返回值
- nodejs 周操作
- jQuery实例之实现滚动广告的功能
- [JS]document.body.clientHeight的取值(转)
- MongoDB学习-环境搭建与配置
- sql循环数据添加
- java枚举类型enum详解
- Xcode7.2 KSImageNamed 安装后无效解决方法
- Python--递归和快速排序 -- quickSort
- Openfire的学习