status timezone sync
This commit is contained in:
@@ -84,7 +84,7 @@ function initChart() {
|
|||||||
chart.onSymbolChanged().subscribe(null, changeSymbol)
|
chart.onSymbolChanged().subscribe(null, changeSymbol)
|
||||||
chart.onIntervalChanged().subscribe(null, changeInterval)
|
chart.onIntervalChanged().subscribe(null, changeInterval)
|
||||||
const tzapi = chart.getTimezoneApi();
|
const tzapi = chart.getTimezoneApi();
|
||||||
tzapi.onTimezoneChanged().subscribe(null, (tz)=>s.timeZone=tz )
|
tzapi.onTimezoneChanged().subscribe(null, (tz)=>{if (tz==='exchange') tz='Etc/UTC'; s.timeZone=tz})
|
||||||
s.timeZone = tzapi.getTimezone().id
|
s.timeZone = tzapi.getTimezone().id
|
||||||
// chart.onHoveredSourceChanged().subscribe(null, ()=>console.log('hovered source changed', arguments))
|
// chart.onHoveredSourceChanged().subscribe(null, ()=>console.log('hovered source changed', arguments))
|
||||||
// chart.selection().onChanged().subscribe(null, s => console.log('selection', chart.selection().allSources()));
|
// chart.selection().onChanged().subscribe(null, s => console.log('selection', chart.selection().allSources()));
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const emit = defineEmits(['update:modelValue'])
|
|||||||
|
|
||||||
const hideDetails = true
|
const hideDetails = true
|
||||||
|
|
||||||
const now = computed(()=>DateTime.fromMillis(1000*props.modelValue).setZone(s.timeZone))
|
const now = computed(()=>DateTime.fromSeconds(props.modelValue).setZone(s.timeZone))
|
||||||
|
|
||||||
const year = computed({
|
const year = computed({
|
||||||
get() { return now.value.year },
|
get() { return now.value.year },
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<v-data-table :headers="datatableHeaders" :items="orders" item-value="id"
|
<v-data-table :headers="datatableHeaders" :items="orders" item-value="id"
|
||||||
item-selectable="selectable" :show-select="false" :show-expand="true">
|
item-selectable="selectable" :show-select="false" :show-expand="true">
|
||||||
<template v-slot:item.start="{ value }">{{ dateString(value) }}</template>
|
<template v-slot:item.start="{ value }">{{ timestampString(value) }}</template>
|
||||||
<template v-slot:item.input="{ item }">
|
<template v-slot:item.input="{ item }">
|
||||||
<span v-if="item.order.amountIsInput">
|
<span v-if="item.order.amountIsInput">
|
||||||
<span v-if="item.state > OrderState.Signing">
|
<span v-if="item.state > OrderState.Signing">
|
||||||
@@ -114,10 +114,13 @@
|
|||||||
</span>
|
</span>
|
||||||
</suspense>
|
</suspense>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-left">
|
<td class="d-flex align-center text-left">
|
||||||
<span class="mx-3">{{ describeTrancheTime(item, true, t) }}</span>
|
<div class="text-right">
|
||||||
<span class="mx-3">{{ describeTrancheTime(item, false, t) }}</span>
|
<div class="mx-3">{{ describeTrancheTime(item, true, t) }}</div>
|
||||||
<span class="mx-3" v-if="t.marketOrder">market order</span>
|
<div class="mx-3">{{ describeTrancheTime(item, false, t) }}</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="mx-3" v-if="t.marketOrder">market order</div>
|
||||||
<line-price class="mx-3" v-if="!t.marketOrder"
|
<line-price class="mx-3" v-if="!t.marketOrder"
|
||||||
:base="item.token0" :quote="item.token1"
|
:base="item.token0" :quote="item.token1"
|
||||||
:b="t.minIntercept" :m="t.minSlope" :is-min="true"
|
:b="t.minIntercept" :m="t.minSlope" :is-min="true"
|
||||||
@@ -126,6 +129,7 @@
|
|||||||
:base="item.token0" :quote="item.token1"
|
:base="item.token0" :quote="item.token1"
|
||||||
:b="t.maxIntercept" :m="t.maxSlope" :is-min="false"
|
:b="t.maxIntercept" :m="t.maxSlope" :is-min="false"
|
||||||
:buy="item.order.tokenIn===item.token1" :show-btn="true"/>
|
:buy="item.order.tokenIn===item.token1" :show-btn="true"/>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -144,7 +148,7 @@ import {useStore} from "@/store/store";
|
|||||||
import {computed, defineAsyncComponent, ref} from "vue";
|
import {computed, defineAsyncComponent, ref} from "vue";
|
||||||
import Btn from "@/components/Btn.vue"
|
import Btn from "@/components/Btn.vue"
|
||||||
import {cancelOrder, PendingOrderState, useWalletStore} from "@/blockchain/wallet.js";
|
import {cancelOrder, PendingOrderState, useWalletStore} from "@/blockchain/wallet.js";
|
||||||
import {dateString} from "@/misc.js";
|
import {timestampString} from "@/misc.js";
|
||||||
import {isOpen, OrderState} from "@/blockchain/orderlib.js";
|
import {isOpen, OrderState} from "@/blockchain/orderlib.js";
|
||||||
import Pulse from "@/components/Pulse.vue";
|
import Pulse from "@/components/Pulse.vue";
|
||||||
|
|
||||||
@@ -243,8 +247,8 @@ const orders = computed(()=>{
|
|||||||
/*
|
/*
|
||||||
o.tranches = o.tranches.map((tranche)=>{
|
o.tranches = o.tranches.map((tranche)=>{
|
||||||
const t = {...tranche}
|
const t = {...tranche}
|
||||||
// t.startTime = t.startTimeIsRelative ? intervalString(t.startTime) : dateString(t.startTime)
|
// t.startTime = t.startTimeIsRelative ? intervalString(t.startTime) : timestampString(t.startTime)
|
||||||
// t.endTime = t.endTimeIsRelative ? intervalString(t.endTime) : dateString(t.endTime)
|
// t.endTime = t.endTimeIsRelative ? intervalString(t.endTime) : timestampString(t.endTime)
|
||||||
return t
|
return t
|
||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
@@ -278,12 +282,12 @@ function describeTrancheTime(st, isStart, t) {
|
|||||||
if( isStart && t.startTime > 0 ) {
|
if( isStart && t.startTime > 0 ) {
|
||||||
const started = t.startTimeIsRelative ? st.start + t.startTime : t.startTime
|
const started = t.startTimeIsRelative ? st.start + t.startTime : t.startTime
|
||||||
result += started*1000 < Date.now() ? 'Activated ' : 'Activates '
|
result += started*1000 < Date.now() ? 'Activated ' : 'Activates '
|
||||||
result += dateString(started) + ' '
|
result += timestampString(started) + ' '
|
||||||
}
|
}
|
||||||
if( !isStart && t.endTime < 4294967295 ) {
|
if( !isStart && t.endTime < 4294967295 ) {
|
||||||
const ended = t.endTimeIsRelative ? st.start + t.endTime : t.endTime
|
const ended = t.endTimeIsRelative ? st.start + t.endTime : t.endTime
|
||||||
result += ended*1000 < Date.now() ? 'Expired ' : 'Expires '
|
result += ended*1000 < Date.now() ? 'Ended ' : 'Ending '
|
||||||
result += dateString(ended)
|
result += timestampString(ended)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ const absoluteTimes = computed(()=>{
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dateStrings = computed(()=>absoluteTimes.value.map((t)=>{
|
const dateStrings = computed(()=>absoluteTimes.value.map((t)=>{
|
||||||
const n = DateTime.fromMillis(1000*t).setZone(s.timeZone)
|
const n = DateTime.fromSeconds(t).setZone(s.timeZone)
|
||||||
const y = n.toLocaleString({year:'numeric'})
|
const y = n.toLocaleString({year:'numeric'})
|
||||||
const m = n.toLocaleString({month:'long'})
|
const m = n.toLocaleString({month:'long'})
|
||||||
const d = n.toLocaleString({day:'numeric'})
|
const d = n.toLocaleString({day:'numeric'})
|
||||||
|
|||||||
@@ -244,7 +244,6 @@ function createInteriorShape(index) {
|
|||||||
interiorShapes.push(shape)
|
interiorShapes.push(shape)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function removeInteriorShape() {
|
function removeInteriorShape() {
|
||||||
if (interiorShapes.length) {
|
if (interiorShapes.length) {
|
||||||
const shape = interiorShapes.pop()
|
const shape = interiorShapes.pop()
|
||||||
|
|||||||
12
src/misc.js
12
src/misc.js
@@ -2,6 +2,7 @@ import {FixedNumber} from "ethers";
|
|||||||
import {usePrefStore, useStore} from "@/store/store.js";
|
import {usePrefStore, useStore} from "@/store/store.js";
|
||||||
import {token} from "@/blockchain/token.js";
|
import {token} from "@/blockchain/token.js";
|
||||||
import Color from "color";
|
import Color from "color";
|
||||||
|
import {DateTime} from "luxon";
|
||||||
|
|
||||||
const QUOTE_SYMBOLS = [
|
const QUOTE_SYMBOLS = [
|
||||||
// in order of preference
|
// in order of preference
|
||||||
@@ -88,11 +89,14 @@ export function intervalString(seconds) {
|
|||||||
return `${(seconds / 86400).toFixed(1)} days`
|
return `${(seconds / 86400).toFixed(1)} days`
|
||||||
}
|
}
|
||||||
|
|
||||||
const _dateFormat = new Intl.DateTimeFormat(undefined, {dateStyle: 'medium', timeStyle: 'short'})
|
export function timestampString(seconds) {
|
||||||
|
const date = DateTime.fromSeconds(seconds).setZone(useStore().timeZone)
|
||||||
|
return dateString(date)
|
||||||
|
}
|
||||||
|
|
||||||
export function dateString(seconds) {
|
|
||||||
const date = new Date(seconds * 1000)
|
export function dateString(datetime) {
|
||||||
return _dateFormat.format(date)
|
return datetime.toLocaleString({dateStyle: 'medium', timeStyle: 'short'})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user