Skip to content

Commit

Permalink
convert nano average to time duration (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
MauserBitfly authored Jun 13, 2024
1 parent 068946b commit 88aef94
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontend/components/dashboard/table/SummaryValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const data = computed(() => {
<b>
{{ $t('common.average') }}:
</b>
{{ $t('common.every_day', {}, data.luck.proposal.average) }}
{{ $t('common.every_x', { duration: formatNanoSecondDuration(data.luck.proposal.average, $t)}) }}
</div>
<br>
<div class="row next_chapter">
Expand All @@ -216,7 +216,7 @@ const data = computed(() => {
<b>
{{ $t('common.average') }}:
</b>
{{ $t('common.every_day', {}, data.luck.sync.average) }}
{{ $t('common.every_x', { duration: formatNanoSecondDuration(data.luck.sync.average, $t)}) }}
</div>
</template>
</BcTooltip>
Expand Down
1 change: 1 addition & 0 deletions frontend/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"expected": "Expected",
"in_day": "In one day | In {count} days",
"every_day": "Every day | Every {count} days",
"every_x":"Every {duration}",
"id": "ID",
"average": "Average",
"index": "Index",
Expand Down
8 changes: 8 additions & 0 deletions frontend/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ export function formatTimeDuration (seconds: number | undefined, t: ComposerTran
return t(translationId, { amount }, amount === 1 ? 1 : 2)
}

export function formatNanoSecondDuration (nano:number | undefined, t: ComposerTranslation):string | undefined {
if (nano === undefined) {
return undefined
}
const seconds = Math.floor(nano / 1000000000)
return formatTimeDuration(seconds, t)
}

export function formatFiat (value:number, currency: string, locales: string, minimumFractionDigits?: number, maximumFractionDigits?: number) {
const formatter = new Intl.NumberFormat(locales, {
style: 'currency',
Expand Down

0 comments on commit 88aef94

Please sign in to comment.