Skip to content

Commit

Permalink
fix time filters
Browse files Browse the repository at this point in the history
  • Loading branch information
carkom committed Feb 22, 2024
1 parent 4d4062e commit eeea9d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/desktop-client/src/components/reports/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ function boundedRange(earliest, start, end) {
return [start, end];
}

export function getLatestRange(offset, addNumber) {
function getLatestRange(offset) {
const end = monthUtils.currentMonth();
const start = monthUtils.subMonths(end, offset);
return [start, end];
}

export function getSpecificRange(offset, addNumber) {
const currMonth = monthUtils.currentMonth();
const start = monthUtils.subMonths(currMonth, offset);
const end = monthUtils.addMonths(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { CategorySelector } from './CategorySelector';
import {
validateStart,
validateEnd,
getLatestRange,
getFullRange,
validateRange,
getSpecificRange,
} from './Header';
import { ModeButton } from './ModeButton';
import { ReportOptions } from './ReportOptions';
Expand Down Expand Up @@ -75,7 +75,7 @@ export function ReportSidebar({
break;
default:
onChangeDates(
...getLatestRange(
...getSpecificRange(
ReportOptions.dateRangeMap.get(cond),
cond === 'Last month' ? 0 : null,
),
Expand Down

0 comments on commit eeea9d0

Please sign in to comment.