Spaces:
Running
Running
start 1.5 * 28 in the past
Browse files- src/main.ts +6 -6
src/main.ts
CHANGED
|
@@ -186,15 +186,15 @@ function renderCharts(activities: Activity[], targetAcwr: number): void {
|
|
| 186 |
// Calculate date range from first activity to today
|
| 187 |
let dateRange: { start: Date; end: Date } | undefined;
|
| 188 |
if (allActivities.length > 0) {
|
| 189 |
-
const sortedAll = [...allActivities].sort((a, b) => a.date.getTime() - b.date.getTime());
|
| 190 |
-
// Normalize to midnight to avoid timezone/time comparison issues
|
| 191 |
-
const startDate = new Date(sortedAll[0].date);
|
| 192 |
-
startDate.setHours(0, 0, 0, 0);
|
| 193 |
-
|
| 194 |
// Use current date/time as end date (today)
|
| 195 |
const endDate = new Date();
|
| 196 |
endDate.setHours(23, 59, 59, 999);
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
dateRange = {
|
| 199 |
start: startDate,
|
| 200 |
end: endDate,
|
|
|
|
| 186 |
// Calculate date range from first activity to today
|
| 187 |
let dateRange: { start: Date; end: Date } | undefined;
|
| 188 |
if (allActivities.length > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
// Use current date/time as end date (today)
|
| 190 |
const endDate = new Date();
|
| 191 |
endDate.setHours(23, 59, 59, 999);
|
| 192 |
+
|
| 193 |
+
// Calculate start date as 1.5 times chronic workload period (28 days) before today
|
| 194 |
+
const startDate = new Date(endDate);
|
| 195 |
+
startDate.setDate(startDate.getDate() - Math.floor(28 * 1.5));
|
| 196 |
+
startDate.setHours(0, 0, 0, 0);
|
| 197 |
+
|
| 198 |
dateRange = {
|
| 199 |
start: startDate,
|
| 200 |
end: endDate,
|