-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f345e97
commit 0cf4464
Showing
23 changed files
with
835 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
.history | ||
node_modules | ||
/dist | ||
package-lock.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/static/css/app.e1992a6b.css → docs/static/css/app.10e8b0b2.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
docs/static/js/app.e597c307.js → docs/static/js/app.9b08825e.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,14 @@ | ||
var staticWeekTime = require('./staticWeekTime') | ||
var staticStrFirst = require('./staticStrFirst') | ||
|
||
var helperGetYMDTime = require('./helperGetYMDTime') | ||
|
||
var getWhatMonth = require('./getWhatMonth') | ||
var toStringDate = require('./toStringDate') | ||
var getWhatWeek = require('./getWhatWeek') | ||
|
||
var isValidDate = require('./isValidDate') | ||
var helperCreateGetDateWeek = require('./helperCreateGetDateWeek') | ||
|
||
/** | ||
* 返回某个月的第几周 | ||
* | ||
* @param {Date} date 日期或数字 | ||
* @param {Number} firstDay 周视图的起始天,默认星期一 | ||
* @return {Number} | ||
*/ | ||
function getMonthWeek (date) { | ||
var monthFirst, monthFirstWeek | ||
var currentDate = toStringDate(date) | ||
if (isValidDate(currentDate)) { | ||
monthFirst = getWhatMonth(currentDate, 0, staticStrFirst) | ||
monthFirstWeek = getWhatWeek(monthFirst, 0, 1) | ||
if (monthFirstWeek < monthFirst) { | ||
monthFirstWeek = getWhatWeek(monthFirst, 1, 1) | ||
} | ||
if (currentDate >= monthFirstWeek) { | ||
return Math.floor((helperGetYMDTime(currentDate) - helperGetYMDTime(monthFirstWeek)) / staticWeekTime) + 1 | ||
} | ||
return getMonthWeek(getWhatWeek(currentDate, 0, 1)) | ||
} | ||
return NaN | ||
} | ||
var getMonthWeek = helperCreateGetDateWeek(function (targetDate) { | ||
return new Date(targetDate.getFullYear(), targetDate.getMonth(), 1) | ||
}) | ||
|
||
module.exports = getMonthWeek |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,14 @@ | ||
var staticDayTime = require('./staticDayTime') | ||
|
||
var toStringDate = require('./toStringDate') | ||
|
||
var isValidDate = require('./isValidDate') | ||
var helperCreateGetDateWeek = require('./helperCreateGetDateWeek') | ||
|
||
/** | ||
* 返回某个年份的第几周 | ||
* | ||
* @param {Date} date 日期或数字 | ||
* @param {Number} firstDay 从年初的星期几为起始开始周开始算,默认星期一 | ||
* @return {Number} | ||
*/ | ||
function getYearWeek (date) { | ||
date = toStringDate(date) | ||
if (isValidDate(date)) { | ||
date.setHours(0, 0, 0, 0) | ||
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7) | ||
var week = new Date(date.getFullYear(), 0, 4) | ||
return Math.round(((date.getTime() - week.getTime()) / staticDayTime + (week.getDay() + 6) % 7 - 3) / 7) + 1 | ||
} | ||
return NaN | ||
} | ||
var getYearWeek = helperCreateGetDateWeek(function (targetDate) { | ||
return new Date(targetDate.getFullYear(), 0, 1) | ||
}) | ||
|
||
module.exports = getYearWeek |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var setupDefaults = require('./setupDefaults') | ||
|
||
var staticWeekTime = require('./staticWeekTime') | ||
|
||
var isNumber = require('./isNumber') | ||
var isValidDate = require('./isValidDate') | ||
var getWhatWeek = require('./getWhatWeek') | ||
|
||
var helperGetDateTime = require('./helperGetDateTime') | ||
|
||
function createGetDateMonthWeek (getStartDate) { | ||
return function (date, firstDay) { | ||
var viewStartDay = isNumber(firstDay) ? firstDay : setupDefaults.firstDayOfWeek | ||
var targetDate = getWhatWeek(date, 0, viewStartDay, viewStartDay) | ||
if (isValidDate(targetDate)) { | ||
var targetOffsetDate = new Date(targetDate.getFullYear(), targetDate.getMonth(), targetDate.getDate()) | ||
var targerStartDate = getStartDate(targetDate) | ||
var targetFirstDay = targerStartDate.getDay() | ||
if (targetFirstDay > viewStartDay) { | ||
targerStartDate.setDate(7 - targetFirstDay + viewStartDay + 1) | ||
} | ||
if (targetFirstDay < viewStartDay) { | ||
targerStartDate.setDate(viewStartDay - targetFirstDay + 1) | ||
} | ||
return Math.floor((helperGetDateTime(targetOffsetDate) - helperGetDateTime(targerStartDate)) / staticWeekTime + 1) | ||
} | ||
return NaN | ||
} | ||
} | ||
|
||
module.exports = createGetDateMonthWeek |
Oops, something went wrong.