aboutsummaryrefslogtreecommitdiff
path: root/packages/demobank-ui
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-01-13 14:59:11 -0300
committerSebastian <sebasjm@gmail.com>2023-01-13 14:59:11 -0300
commit42acac06aac7bdb34f9231b3b1ec0e8dfcab9821 (patch)
treeb5b3a655512fbf92ec7ba6dbf5e72cf51b978488 /packages/demobank-ui
parenta31b8c3c3105d0ba11f2a1c513c6b6bec3ebeb49 (diff)
fix: date parsing
Diffstat (limited to 'packages/demobank-ui')
-rw-r--r--packages/demobank-ui/src/components/Transactions/state.ts20
-rw-r--r--packages/demobank-ui/src/components/Transactions/views.tsx4
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 ? "-" : ""}