diff --git a/src/components/MeritSummaryCard.svelte b/src/components/MeritSummaryCard.svelte index e26c50d..4095e7b 100644 --- a/src/components/MeritSummaryCard.svelte +++ b/src/components/MeritSummaryCard.svelte @@ -11,7 +11,7 @@ import { Separator } from '$lib/components/ui/separator/index.js'; import * as Table from '@/components/ui/table'; import { Rocket, RocketATagFilter } from '@/event_helpers/rockets'; - import { getCuckPrice, getRocketURL, unixToRelativeTime } from '@/helpers'; + import { formatReferenceTime, getCuckPrice, getRocketURL, unixToRelativeTime } from '@/helpers'; import { derived } from 'svelte/store'; import { goto } from '$app/navigation'; @@ -51,6 +51,10 @@ } } + $: referenceTime = cuckPrice + ? formatReferenceTime(((merit.Sats / 100000000) * cuckPrice) / 70) + : '...'; + let votes = derived(_votes, ($_votes) => { return new MapOfVotes($_votes, parsedRocket, merit).Votes; }); @@ -156,13 +160,12 @@
Analysis
A competent freelance developer earns $70 CuckLoserBucks an hour (on average). Using - this rate, the contributor is claiming to have spent about {merit.Sats / 1000} hours working - on this. + this rate, the contributor is claiming to have spent about {referenceTime} working on this.
Reference Time
-
{merit.Sats / 1000} hours
+
{referenceTime}
diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index 6d0b63e..6fcdb95 100644 --- a/src/lib/helpers.ts +++ b/src/lib/helpers.ts @@ -57,6 +57,25 @@ export function unixToRelativeTime(timestamp: number): string { } } +export function formatReferenceTime(hours: number) { + const totalMinutes = Math.round(hours * 60); + const wholeHours = Math.floor(totalMinutes / 60); + const remainingMinutes = totalMinutes % 60; + + let result = ''; + + if (wholeHours > 0) { + result += `${wholeHours} hour${wholeHours > 1 ? 's' : ''}`; + } + + if (remainingMinutes > 0) { + if (result.length > 0) result += ' and '; + result += `${remainingMinutes} minute${remainingMinutes > 1 ? 's' : ''}`; + } + + return result || '0 minutes'; +} + export async function getCuckPrice(): Promise { try { var url = 'https://api.coindesk.com/v1/bpi/currentprice.json';