Skip to content

Commit 5260396

Browse files
author
sheepzh
committed
Fix average time of this month (#149)
1 parent e567b74 commit 5260396

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "timer",
3-
"version": "1.2.6",
3+
"version": "1.2.7",
44
"description": "Web timer",
55
"homepage": "https://github.com/sheepzh/timer",
66
"scripts": {

src/popup/components/footer/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,25 @@ function calculateDateRange(duration: timer.popup.Duration, weekStart: timer.opt
3636
if (weekStartAsNormal) {
3737
return getWeekTime(now, locale === 'zh_CN')
3838
} else {
39+
const weekOffset: number = weekStart as number
3940
// Returns 0 - 6 means Monday to Sunday
4041
const weekDayNow = getWeekDay(now, true)
4142
const optionWeekDay = weekDayNow + 1
4243
let start: Date = undefined
4344
if (optionWeekDay === weekStart) {
4445
start = now
4546
} else if (optionWeekDay < weekStart) {
46-
const millDelta = (optionWeekDay + 7 - weekStart) * MILL_PER_DAY
47+
const millDelta = (optionWeekDay + 7 - weekOffset) * MILL_PER_DAY
4748
start = new Date(now.getTime() - millDelta)
4849
} else {
49-
const millDelta = (optionWeekDay - weekStart) * MILL_PER_DAY
50+
const millDelta = (optionWeekDay - weekOffset) * MILL_PER_DAY
5051
start = new Date(now.getTime() - millDelta)
5152
}
5253
return [start, now]
5354
}
5455
} else if (duration == 'thisMonth') {
55-
return getMonthTime(now)
56+
const startOfMonth = getMonthTime(now)[0]
57+
return [startOfMonth, now]
5658
}
5759
}
5860

0 commit comments

Comments
 (0)