Skip to content

Commit cdb70a3

Browse files
Fix Graph Date Issues
- When using toISOString() it would change the date time zone so did this instead. Now graphs are working as intended
1 parent 30e6054 commit cdb70a3

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/graphMonth.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ async function getLast30Days() {
4343
for (let i = 29; i >= 0; i--) {
4444
const date = new Date(today);
4545
date.setDate(today.getDate() - i);
46-
const formattedDate = date.toISOString().slice(0, 10); // Get yyyy-mm-dd format
46+
const year = date.getFullYear();
47+
const month = String(date.getMonth() + 1).padStart(2, '0');
48+
const day = String(date.getDate()).padStart(2, '0');
49+
const formattedDate = `${year}-${month}-${day}`;
4750
labels.push(formattedDate);
4851
}
4952
return labels;

src/graphWeekCompare.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ async function getPreviousDays(dayCount) {
120120
for (let i = dayCount; i >= 0; i--) {
121121
const date = new Date(today);
122122
date.setDate(today.getDate() - i);
123-
const formattedDate = date.toISOString().slice(0, 10);
123+
const year = date.getFullYear();
124+
const month = String(date.getMonth() + 1).padStart(2, '0');
125+
const day = String(date.getDate()).padStart(2, '0');
126+
const formattedDate = `${year}-${month}-${day}`;
127+
124128
labels.push(formattedDate);
125129
}
126130
return labels;

0 commit comments

Comments
 (0)