Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change time format to 24h #1800

Merged
merged 2 commits into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [\#1432](https://github.com/cosmos/voyager/issues/1432) Moved @tendermint/UI components back into the Voyager repository @faboweb
- Improved the readme @faboweb
- [\#1792](https://github.com/cosmos/voyager/pull/1792) removed mocked demo mode @fedekunze
- [\#1720](https://github.com/cosmos/voyager/issues/1720) Time format from 12 to 24h @sabau

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export default {
},
computed: {
date() {
return moment(this.time).format(`h:mm a`)
const time = moment(this.time)
return time.format(
`${moment().isSame(time, `day`) ? `` : `YYYY/MM/DD `}HH:mm`
)
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/renderer/vuex/modules/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default ({ node }) => {
txCategories.forEach(category => {
state[category].forEach(t => {
if (t.height === blockHeight && blockMetaInfo) {
Vue.set(t, `time`, blockMetaInfo.header.time)
// time seems to be an ISO string, but we are expecting a Number type
Vue.set(t, `time`, new Date(blockMetaInfo.header.time).getTime())
}
})
})
Expand Down Expand Up @@ -107,7 +108,9 @@ export default ({ node }) => {
return response ? uniqBy(transactionsPlusType, `hash`) : []
},
async enrichTransactions({ dispatch }, { transactions }) {
const blockHeights = new Set(transactions.map(({ height }) => height))
const blockHeights = new Set(
transactions.map(({ height }) => parseInt(height))
)
await Promise.all(
[...blockHeights].map(blockHeight =>
dispatch(`queryTransactionTime`, { blockHeight })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ exports[`TmLiAnyTransaction shows bank transactions 1`] = `
>
Block #3436 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down Expand Up @@ -123,7 +123,7 @@ exports[`TmLiAnyTransaction shows stake transactions 1`] = `
>
Block #568 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down Expand Up @@ -173,7 +173,7 @@ exports[`TmLiAnyTransaction shows unknown transactions 1`] = `
>
Block #3436 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ exports[`TmLiGovTransaction deposits should show deposits 1`] = `
>
Block #56675 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down Expand Up @@ -133,7 +133,7 @@ exports[`TmLiGovTransaction proposals should show proposals submission transacti
>
Block #56673 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ exports[`TmLiStakeTransaction delegations should show delegations 1`] = `
>
Block #568 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down Expand Up @@ -136,7 +136,7 @@ exports[`TmLiStakeTransaction redelegations should show redelegations and calcul
>
Block #567 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down Expand Up @@ -205,7 +205,7 @@ exports[`TmLiStakeTransaction unbonding delegations should default to ended if n
>
Block #569 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down Expand Up @@ -274,7 +274,7 @@ exports[`TmLiStakeTransaction unbonding delegations should show unbonding delega
>
Block #569 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down Expand Up @@ -347,7 +347,7 @@ exports[`TmLiStakeTransaction unbonding delegations should show unbondings and c
>
Block #569 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ exports[`TmLiTransaction has the expected html structure 1`] = `
>
Block #500 
</a>
@ 12:00 am
@ 00:00

</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ Array [
Object {
"hash": "A7C6DE5CB923AF08E6088F1348047F16BABB9F48",
"height": 160,
"time": 10160,
"time": 42000,
"tx": Object {
"value": Object {
"msg": Array [
Expand All @@ -754,7 +754,7 @@ Array [
Object {
"hash": "A7C6FDE5CA923AF08E6088F1348047F16BABB9F48",
"height": 170,
"time": 10170,
"time": 42000,
"tx": Object {
"value": Object {
"msg": Array [
Expand Down
4 changes: 2 additions & 2 deletions test/unit/specs/store/transactions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ describe(`Module: Transactions`, () => {
blockHeight: `3436`,
blockMetaInfo: {
header: {
time: 1042
time: 42000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is caused by the global Date override in jest

}
}
})
expect(
store.state.transactions.wallet.find(tx => tx.height === `3436`).time
).toBe(1042)
).toBe(42000)
})

it(`should clear session data`, () => {
Expand Down