Group transactions by locale TZ (#1883)

This commit is contained in:
Fernando 2021-02-11 05:17:56 -03:00 committed by GitHub
parent 43287dd018
commit e9bc89488f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -22,7 +22,7 @@ import {
import { UPDATE_TRANSACTION_DETAILS } from 'src/logic/safe/store/actions/fetchTransactionDetails'
import { AppReduxState } from 'src/store'
import { getUTCStartOfDate } from 'src/utils/date'
import { getLocalStartOfDate } from 'src/utils/date'
import { sameString } from 'src/utils/strings'
import { sortObject } from 'src/utils/objects'
@ -78,7 +78,7 @@ export const gatewayTransactions = handleActions<AppReduxState['gatewayTransacti
}
if (isTransactionSummary(value)) {
const startOfDate = getUTCStartOfDate(value.transaction.timestamp)
const startOfDate = getLocalStartOfDate(value.transaction.timestamp)
if (typeof history[startOfDate] === 'undefined') {
history[startOfDate] = []

View File

@ -20,6 +20,12 @@ export const getUTCStartOfDate = (timestamp: number): number => {
return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0, 0)
}
export const getLocalStartOfDate = (timestamp: number): number => {
const date = new Date(timestamp)
return date.setHours(0, 0, 0, 0)
}
export const formatWithSchema = (timestamp: number, schema: string): string => format(timestamp, schema)
export const formatTime = (timestamp: number): string => formatWithSchema(timestamp, 'h:mm a')