orderspec refactor for server and web

This commit is contained in:
Tim Olson
2023-12-07 18:37:11 -04:00
parent 545583586c
commit 83619ea248
12 changed files with 306 additions and 110 deletions

View File

@@ -59,3 +59,21 @@ export function routeInverted(route) {
return route && (route.token0 === s.tokenA) === s.inverted
}
export function intervalString(seconds) {
if( seconds < 1 )
return 'now'
else if( seconds < 60 )
return `${seconds} seconds`
else if( seconds < 3600 )
return `${(seconds/60).toFixed(1)} minutes`
else if( seconds < 86400 )
return `${(seconds/3600).toFixed(1)} hours`
else
return `${(seconds/86400).toFixed(1)} days`
}
const _dateFormat = new Intl.DateTimeFormat( undefined, {dateStyle: 'medium', timeStyle: 'short'})
export function dateString(seconds) {
const date = new Date(seconds*1000)
return _dateFormat.format(date)
}