mirror of
https://github.com/usememos/memos.git
synced 2025-11-09 08:52:29 +08:00
fix: update UsageHeatMap.tsx to account for daylight savings (#696)
This commit is contained in:
parent
43b22ce55f
commit
4d9857ce18
1 changed files with 5 additions and 1 deletions
|
|
@ -46,7 +46,11 @@ const UsageHeatMap = () => {
|
|||
for (const record of data) {
|
||||
const index = (utils.getDateStampByDate(record * 1000) - beginDayTimestamp) / (1000 * 3600 * 24) - 1;
|
||||
if (index >= 0) {
|
||||
newStat[index].count += 1;
|
||||
// because of dailight savings, some days may be 23 hours long instead of 24 hours long
|
||||
// this causes the calculations to yield weird indices such as 40.93333333333
|
||||
// rounding them may not give you the exact day on the heat map, but it's not too bad
|
||||
const exactIndex = +index.toFixed(0);
|
||||
newStat[exactIndex].count += 1;
|
||||
}
|
||||
}
|
||||
setAllStat([...newStat]);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue