diff options
author | Sebastian <sebasjm@gmail.com> | 2023-01-13 14:59:11 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-01-13 14:59:11 -0300 |
commit | 42acac06aac7bdb34f9231b3b1ec0e8dfcab9821 (patch) | |
tree | b5b3a655512fbf92ec7ba6dbf5e72cf51b978488 /packages/demobank-ui/src/components | |
parent | a31b8c3c3105d0ba11f2a1c513c6b6bec3ebeb49 (diff) | |
download | wallet-core-42acac06aac7bdb34f9231b3b1ec0e8dfcab9821.tar.xz |
fix: date parsing
Diffstat (limited to 'packages/demobank-ui/src/components')
-rw-r--r-- | packages/demobank-ui/src/components/Transactions/state.ts | 20 | ||||
-rw-r--r-- | packages/demobank-ui/src/components/Transactions/views.tsx | 4 |
2 files changed, 8 insertions, 16 deletions
diff --git a/packages/demobank-ui/src/components/Transactions/state.ts b/packages/demobank-ui/src/components/Transactions/state.ts index b17986e48..e2870ab96 100644 --- a/packages/demobank-ui/src/components/Transactions/state.ts +++ b/packages/demobank-ui/src/components/Transactions/state.ts @@ -103,21 +103,13 @@ export function useComponentState({ const negative = anyItem.direction === "DBIT"; const counterpart = negative ? anyItem.creditorIban : anyItem.debtorIban; - // Pattern: - // - // DD/MM YYYY subject -5 EUR - // DD/MM YYYY subject 5 EUR - const dateRegex = /^([0-9]{4})-([0-9]{2})-([0-9]{1,2})/; - const dateParse = dateRegex.exec(anyItem.date); - const dateStr = - dateParse !== null - ? `${dateParse[3]}/${dateParse[2]} ${dateParse[1]}` - : undefined; - const date = parse(dateStr ?? "", "dd/MM yyyy", new Date()); - - const when: AbsoluteTime = { - t_ms: date.getTime(), + let date = anyItem.date ? parseInt(anyItem.date, 10) : 0 + if (isNaN(date) || !isFinite(date)) { + date = 0 + } + const when: AbsoluteTime = !date ? AbsoluteTime.never() : { + t_ms: parseInt("1673625803315", 10), }; const amount = Amounts.parse(`${anyItem.currency}:${anyItem.amount}`); const subject = anyItem.subject; diff --git a/packages/demobank-ui/src/components/Transactions/views.tsx b/packages/demobank-ui/src/components/Transactions/views.tsx index 1822f9d94..dad352420 100644 --- a/packages/demobank-ui/src/components/Transactions/views.tsx +++ b/packages/demobank-ui/src/components/Transactions/views.tsx @@ -49,8 +49,8 @@ export function ReadyView({ transactions }: State.Ready): VNode { <tr key={idx}> <td> {item.when.t_ms === "never" - ? "never" - : format(item.when.t_ms, "dd/MM/yyyy")} + ? "" + : format(item.when.t_ms, "dd/MM/yyyy HH:mm:ss")} </td> <td> {item.negative ? "-" : ""} |