Update balance widget 7d/30d intervals

This commit is contained in:
Mononaut 2024-05-12 16:27:57 +00:00
parent 2fa33b749c
commit d7b0923000
No known key found for this signature in database
GPG key ID: A3F058E41374C04E

View file

@ -57,8 +57,9 @@ export class BalanceWidgetComponent implements OnInit, OnChanges {
calculateStats(summary: AddressTxSummary[]): void { calculateStats(summary: AddressTxSummary[]): void {
let weekTotal = 0; let weekTotal = 0;
let monthTotal = 0; let monthTotal = 0;
const weekAgo = (Date.now() / 1000) - (60 * 60 * 24 * 7);
const monthAgo = (Date.now() / 1000) - (60 * 60 * 24 * 30); const weekAgo = (new Date(new Date().setHours(0, 0, 0, 0) - (7 * 24 * 60 * 60 * 1000)).getTime()) / 1000;
const monthAgo = (new Date(new Date().setHours(0, 0, 0, 0) - (30 * 24 * 60 * 60 * 1000)).getTime()) / 1000;
for (let i = 0; i < summary.length && summary[i].time >= monthAgo; i++) { for (let i = 0; i < summary.length && summary[i].time >= monthAgo; i++) {
monthTotal += summary[i].value; monthTotal += summary[i].value;
if (summary[i].time >= weekAgo) { if (summary[i].time >= weekAgo) {