Skip to content

Commit 045d751

Browse files
committed
fix: set default end date to yesterday on weekly downloads chart
1 parent 3277348 commit 045d751

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

app/composables/useNpmRegistry.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,14 @@ export function usePackageWeeklyDownloadEvolution(
171171
async () => {
172172
const packageName = toValue(name)
173173
const { weeks = 12, endDate } = toValue(options) ?? {}
174-
const end = endDate ? new Date(`${endDate}T00:00:00.000Z`) : new Date()
174+
175+
const today = new Date()
176+
const yesterday = new Date(
177+
Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate() - 1),
178+
)
179+
180+
const end = endDate ? new Date(`${endDate}T00:00:00.000Z`) : yesterday
181+
175182
const start = addDays(end, -(weeks * 7) + 1)
176183
const startIso = toIsoDateString(start)
177184
const endIso = toIsoDateString(end)

0 commit comments

Comments
 (0)