From e63c472f52da42205f1c8c27b62bcd1751f884f1 Mon Sep 17 00:00:00 2001 From: Felix Mohr Date: Sun, 21 Jun 2020 07:13:22 +0200 Subject: [PATCH 1/6] updating date format to yyyy-mm-dd in finance app --- apps/finance/app/src/components/Transfers.js | 4 ++-- apps/finance/app/src/components/TransfersFilters.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/finance/app/src/components/Transfers.js b/apps/finance/app/src/components/Transfers.js index f10861f503..eb33b6702a 100644 --- a/apps/finance/app/src/components/Transfers.js +++ b/apps/finance/app/src/components/Transfers.js @@ -30,7 +30,7 @@ import { useIdentity, IdentityContext } from './IdentityManager/IdentityManager' import LocalIdentityBadge from './LocalIdentityBadge/LocalIdentityBadge' import useFilteredTransfers from './useFilteredTransfers' -const formatDate = date => format(date, 'dd/MM/yy') +const formatDate = date => format(date, 'yy-MM-dd') const getDownloadData = async (transfers, tokenDetails, resolveAddress) => { const mappedData = await Promise.all( @@ -219,7 +219,7 @@ const Transfers = React.memo(({ tokens, transactions }) => { return [ ,
) From 421b8b0e02b0b10e47a1606654135881c4d3b4bd Mon Sep 17 00:00:00 2001 From: Felix Mohr Date: Sun, 21 Jun 2020 07:16:45 +0200 Subject: [PATCH 2/6] incorrect date format at formatDate fixed --- apps/finance/app/src/components/Transfers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/finance/app/src/components/Transfers.js b/apps/finance/app/src/components/Transfers.js index eb33b6702a..93b0d5d44e 100644 --- a/apps/finance/app/src/components/Transfers.js +++ b/apps/finance/app/src/components/Transfers.js @@ -30,7 +30,7 @@ import { useIdentity, IdentityContext } from './IdentityManager/IdentityManager' import LocalIdentityBadge from './LocalIdentityBadge/LocalIdentityBadge' import useFilteredTransfers from './useFilteredTransfers' -const formatDate = date => format(date, 'yy-MM-dd') +const formatDate = date => format(date, 'yyyy-MM-dd') const getDownloadData = async (transfers, tokenDetails, resolveAddress) => { const mappedData = await Promise.all( From e09faa8d22378df911fae3a1b95bd1bbaf51e24b Mon Sep 17 00:00:00 2001 From: Felix Mohr Date: Wed, 24 Jun 2020 19:10:12 +0200 Subject: [PATCH 3/6] using iso short format for dates in agent app --- apps/agent/app/src/components/TransactionFilters.js | 1 + apps/agent/app/src/components/Transactions.js | 6 +++--- apps/agent/app/src/components/useDownloadData.js | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/agent/app/src/components/TransactionFilters.js b/apps/agent/app/src/components/TransactionFilters.js index 6df36165c7..3882fdc1be 100644 --- a/apps/agent/app/src/components/TransactionFilters.js +++ b/apps/agent/app/src/components/TransactionFilters.js @@ -44,6 +44,7 @@ function TransactionFilters({ format={MMDDYY_FORMAT} onChange={onDateRangeChange} startDate={dateRangeFilter.start} + format={'YYYY-MM-DD'} /> ) diff --git a/apps/agent/app/src/components/Transactions.js b/apps/agent/app/src/components/Transactions.js index 080024defe..02c13e15cb 100644 --- a/apps/agent/app/src/components/Transactions.js +++ b/apps/agent/app/src/components/Transactions.js @@ -29,7 +29,7 @@ import TransactionFilters from './TransactionFilters' import { TRANSACTION_TYPES_LABELS } from '../transaction-types' import useDownloadData from './useDownloadData' import useFilteredTransactions from './useFilteredTransactions' -import { ISO_FORMAT, MMDDYY_FUNC_FORMAT } from '../lib/date-utils' +import { ISO_SHORT_FORMAT } from '../lib/date-utils' import { addressesEqual, toChecksumAddress } from '../lib/web3-utils' import AgentSvg from './assets/agent_badge.svg' @@ -175,7 +175,7 @@ const Transactions = React.memo(function Transactions({ const [{ token, amount, to, from } = {}] = tokenTransfers const onlyOne = tokenTransfers.length === 1 const entity = to || from - const formattedDate = format(date, ISO_FORMAT) + const formattedDate = format(date, ISO_SHORT_FORMAT) const isValidEntity = typeof targetContract === 'string' && tokenTransfers.length > 0 @@ -188,7 +188,7 @@ const Transactions = React.memo(function Transactions({ color: ${theme.surfaceContent}; `} > - {format(date, MMDDYY_FUNC_FORMAT)} + {format(date, ISO_SHORT_FORMAT)} ) const badgeNode = onlyOne ? ( diff --git a/apps/agent/app/src/components/useDownloadData.js b/apps/agent/app/src/components/useDownloadData.js index c94a5f83d5..85a8e54ec5 100644 --- a/apps/agent/app/src/components/useDownloadData.js +++ b/apps/agent/app/src/components/useDownloadData.js @@ -4,7 +4,7 @@ import { saveAs } from 'file-saver' import { formatTokenAmount } from '@aragon/ui' import { IdentityContext } from './IdentityManager/IdentityManager' import { toChecksumAddress } from '../lib/web3-utils' -import { formatDate, ISO_SHORT_FORMAT } from '../lib/date-utils' +import { ISO_SHORT_FORMAT } from '../lib/date-utils' import { TRANSACTION_TYPES_LABELS } from '../transaction-types' // Transforms a two dimensional array into a CSV data structure @@ -41,7 +41,7 @@ async function getDownloadData({ transactions, tokenDetails, resolveAddress }) { }) ) return [ - formatDate(date), + format(date, ISO_SHORT_FORMAT), source, recipient, TRANSACTION_TYPES_LABELS[type], From 2071b67eb02fa9f3878e4bd33adec227a53a2685 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Thu, 25 Jun 2020 08:59:54 +0200 Subject: [PATCH 4/6] Agent: clean up unused date utilities and formats --- apps/agent/app/src/components/TransactionFilters.js | 4 +--- apps/agent/app/src/lib/date-utils.js | 9 --------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/apps/agent/app/src/components/TransactionFilters.js b/apps/agent/app/src/components/TransactionFilters.js index 3882fdc1be..2f577f402e 100644 --- a/apps/agent/app/src/components/TransactionFilters.js +++ b/apps/agent/app/src/components/TransactionFilters.js @@ -1,7 +1,6 @@ import React from 'react' import { DateRangePicker, DropDown, GU } from '@aragon/ui' import { noop } from '../lib/utils' -import { MMDDYY_FORMAT } from '../lib/date-utils' function TransactionFilters({ dateRangeFilter, @@ -40,10 +39,9 @@ function TransactionFilters({ onChange={onTokenChange} /> diff --git a/apps/agent/app/src/lib/date-utils.js b/apps/agent/app/src/lib/date-utils.js index b7ba913299..495b33bec7 100644 --- a/apps/agent/app/src/lib/date-utils.js +++ b/apps/agent/app/src/lib/date-utils.js @@ -1,10 +1 @@ -import { format } from 'date-fns' - -export const MMDDYY_FORMAT = 'MM/DD/YY' -export const MMDDYY_FUNC_FORMAT = 'MM/dd/yy' -export const ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ss" export const ISO_SHORT_FORMAT = 'yyyy-MM-dd' - -export function formatDate(date) { - return format(date, MMDDYY_FUNC_FORMAT) -} From 128181cc079f482be8642854f7e3b76b51925dfb Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Thu, 25 Jun 2020 09:18:05 +0200 Subject: [PATCH 5/6] Agent: render long iso format for date's title --- apps/agent/app/src/components/Transactions.js | 7 ++++--- apps/agent/app/src/lib/date-utils.js | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/agent/app/src/components/Transactions.js b/apps/agent/app/src/components/Transactions.js index 02c13e15cb..6332947980 100644 --- a/apps/agent/app/src/components/Transactions.js +++ b/apps/agent/app/src/components/Transactions.js @@ -29,7 +29,7 @@ import TransactionFilters from './TransactionFilters' import { TRANSACTION_TYPES_LABELS } from '../transaction-types' import useDownloadData from './useDownloadData' import useFilteredTransactions from './useFilteredTransactions' -import { ISO_SHORT_FORMAT } from '../lib/date-utils' +import { ISO_SHORT_FORMAT, ISO_LONG_FORMAT } from '../lib/date-utils' import { addressesEqual, toChecksumAddress } from '../lib/web3-utils' import AgentSvg from './assets/agent_badge.svg' @@ -176,19 +176,20 @@ const Transactions = React.memo(function Transactions({ const onlyOne = tokenTransfers.length === 1 const entity = to || from const formattedDate = format(date, ISO_SHORT_FORMAT) + const formattedLongDate = format(date, ISO_LONG_FORMAT) const isValidEntity = typeof targetContract === 'string' && tokenTransfers.length > 0 const dateNode = ( ) const badgeNode = onlyOne ? ( diff --git a/apps/agent/app/src/lib/date-utils.js b/apps/agent/app/src/lib/date-utils.js index 495b33bec7..8ddfcd9693 100644 --- a/apps/agent/app/src/lib/date-utils.js +++ b/apps/agent/app/src/lib/date-utils.js @@ -1 +1,2 @@ export const ISO_SHORT_FORMAT = 'yyyy-MM-dd' +export const ISO_LONG_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSxxx" From a2fe820972735e019ca14e90b4bc9cdf2e284abd Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Thu, 25 Jun 2020 09:12:58 +0200 Subject: [PATCH 6/6] Finance: align formatDate() usages --- apps/finance/app/src/components/Transfers.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/finance/app/src/components/Transfers.js b/apps/finance/app/src/components/Transfers.js index 93b0d5d44e..3806cbe54b 100644 --- a/apps/finance/app/src/components/Transfers.js +++ b/apps/finance/app/src/components/Transfers.js @@ -58,11 +58,11 @@ const getDownloadData = async (transfers, tokenDetails, resolveAddress) => { } const getDownloadFilename = (appAddress, { start, end }) => { - const today = format(Date.now(), 'yyyy-MM-dd') + const today = formatDate(Date.now()) let filename = `finance_${appAddress}_${today}.csv` if (start && end) { - const formattedStart = format(start, 'yyyy-MM-dd') - const formattedEnd = format(end, 'yyyy-MM-dd') + const formattedStart = formatDate(start) + const formattedEnd = formatDate(end) filename = `finance_${appAddress}_${formattedStart}_to_${formattedEnd}.csv` } return filename @@ -219,7 +219,7 @@ const Transfers = React.memo(({ tokens, transactions }) => { return [ ,