Skip to content

A local-first personal finance app

Fix Parse for Date Range (#3735)

Neilf25dc1f261b1
diff --git a/packages/desktop-client/src/components/reports/DateRange.tsx b/packages/desktop-client/src/components/reports/DateRange.tsx
index 6734a0b8ec..29d743064b 100644
--- a/packages/desktop-client/src/components/reports/DateRange.tsx
+++ b/packages/desktop-client/src/components/reports/DateRange.tsx
@@ -2,6 +2,8 @@ import React, { type ReactElement } from 'react';
import * as d from 'date-fns';
+import * as monthUtils from 'loot-core/src/shared/months';
+
import { theme } from '../../style';
import { styles } from '../../style/styles';
import { Block } from '../common/Block';
@@ -14,8 +16,8 @@ type DateRangeProps = {
};
function checkDate(date: string) {
- const dateParsed = new Date(date);
- if (dateParsed.toString() !== 'Invalid Date') {
+ const dateParsed = monthUtils.parseDate(date);
+ if (dateParsed) {
return d.format(dateParsed, 'yyyy-MM-dd');
} else {
return null;
diff --git a/upcoming-release-notes/3735.md b/upcoming-release-notes/3735.md
new file mode 100644
index 0000000000..d673a6f13a
--- /dev/null
+++ b/upcoming-release-notes/3735.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [carkom]
+---
+
+Fix parse date in DateRange element which is causing the cards to display the wrong dates.