Skip to content

Commit

Permalink
fix timeframe
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixTJDietrich committed Oct 5, 2024
1 parent ad978da commit 23352fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions webapp/src/app/home/leaderboard/filter/filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, computed, effect, input, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { Router, RouterLink } from '@angular/router';
import dayjs from 'dayjs';
import weekOfYear from 'dayjs/plugin/weekOfYear';
import isoWeek from 'dayjs/plugin/isoWeek';
import { BrnSelectModule } from '@spartan-ng/ui-select-brain';
import { HlmSelectModule } from '@spartan-ng/ui-select-helm';
import { HlmLabelModule } from '@spartan-ng/ui-label-helm';
Expand All @@ -14,10 +14,10 @@ interface SelectOption {
label: string;
}

dayjs.extend(weekOfYear);
dayjs.extend(isoWeek);

function formatLabel(startDate: dayjs.Dayjs, endDate: dayjs.Dayjs | undefined) {
const calendarWeek = startDate.week();
const calendarWeek = startDate.isoWeek();
if (!endDate) {
return `CW\xa0${calendarWeek}:\xa0${startDate.format('MMM D')}\xa0-\xa0Today`;
}
Expand All @@ -44,12 +44,12 @@ export class LeaderboardFilterComponent {
value = signal<string>(`${this.after()}.${this.before()}`);

placeholder = computed(() => {
return formatLabel(dayjs(this.after()) ?? dayjs().day(1), this.before() === undefined ? undefined : dayjs(this.before()));
return formatLabel(dayjs(this.after()) ?? dayjs().isoWeekday(1), this.before() === undefined ? undefined : dayjs(this.before()));
});

options = computed(() => {
const now = dayjs();
let currentDate = dayjs().day(1);
let currentDate = dayjs().isoWeekday(1);
const options: SelectOption[] = [
{
id: now.unix(),
Expand Down

0 comments on commit 23352fa

Please sign in to comment.