-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
997a703
commit 5de133d
Showing
4 changed files
with
13 additions
and
41 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
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 |
---|---|---|
|
@@ -85,9 +85,6 @@ | |
margin-top: -3px; | ||
} | ||
} | ||
.star { | ||
svg {} | ||
} | ||
.language { | ||
span { | ||
border-radius: 50%; | ||
|
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,38 +1,13 @@ | ||
export function theWeek(str) { | ||
let totalDays = 0; | ||
const now = str ? new Date(str) : new Date(); | ||
let years = now.getYear(); | ||
if (years < 1000) years += 1900; | ||
|
||
const days = new Array(12); | ||
days[0] = 31; | ||
days[2] = 31; | ||
days[3] = 30; | ||
days[4] = 31; | ||
days[5] = 30; | ||
days[6] = 31; | ||
days[7] = 31; | ||
days[8] = 30; | ||
days[9] = 31; | ||
days[10] = 30; | ||
days[11] = 31; | ||
|
||
// 判断是否为闰年,针对2月的天数进行计算 | ||
if (Math.round(now.getYear() / 4) === now.getYear() / 4) { | ||
days[1] = 29; | ||
} else { | ||
days[1] = 28; | ||
var today = new Date(); | ||
var firstDay = new Date(today.getFullYear(), 0, 1); | ||
var dayOfWeek = firstDay.getDay(); | ||
var spendDay = 1; | ||
if (dayOfWeek != 0) { | ||
spendDay = 7 - dayOfWeek + 1; | ||
} | ||
if (now.getMonth() === 0) { | ||
totalDays += now.getDate(); | ||
} else { | ||
const curMonth = now.getMonth(); | ||
for (let count = 1; count <= curMonth; count += 1) { | ||
totalDays += days[count - 1]; | ||
} | ||
totalDays += now.getDate(); | ||
} | ||
// 得到第几周 | ||
const week = Math.round(totalDays / 7); | ||
return week; | ||
firstDay = new Date(today.getFullYear(), 0, 1 + spendDay); | ||
var d = Math.ceil((today.valueOf() - firstDay.valueOf()) / 86400000); | ||
var result = Math.ceil(d / 7); | ||
return result + 1; | ||
} |