2022-07-07 05:19:05 +08:00
|
|
|
<script>
|
2023-09-30 16:58:14 +08:00
|
|
|
import tooltip from "@/actions/tooltip";
|
|
|
|
import CommonHelper from "@/utils/CommonHelper";
|
|
|
|
|
2022-07-07 05:19:05 +08:00
|
|
|
export let date = "";
|
2022-09-29 02:55:18 +08:00
|
|
|
|
2022-10-30 16:28:14 +08:00
|
|
|
$: dateOnly = date ? date.substring(0, 10) : null;
|
|
|
|
|
|
|
|
$: timeOnly = date ? date.substring(10, 19) : null;
|
2023-09-30 16:58:14 +08:00
|
|
|
|
|
|
|
const tooltipData = {
|
|
|
|
// generate the tooltip text as getter to speed up the initial load
|
|
|
|
// in case the component is used with large number of items
|
|
|
|
get text() {
|
|
|
|
return CommonHelper.formatToLocalDate(date) + " Local";
|
|
|
|
},
|
|
|
|
};
|
2022-07-07 05:19:05 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if date}
|
2023-09-30 16:58:14 +08:00
|
|
|
<div class="datetime" use:tooltip={tooltipData}>
|
2022-10-30 16:28:14 +08:00
|
|
|
<div class="date">{dateOnly}</div>
|
|
|
|
<div class="time">{timeOnly} UTC</div>
|
|
|
|
</div>
|
2022-07-07 05:19:05 +08:00
|
|
|
{:else}
|
|
|
|
<span class="txt txt-hint">N/A</span>
|
|
|
|
{/if}
|
2022-10-30 16:28:14 +08:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.datetime {
|
2023-09-30 16:58:14 +08:00
|
|
|
display: inline-block;
|
|
|
|
vertical-align: top;
|
|
|
|
white-space: nowrap;
|
2022-10-30 16:28:14 +08:00
|
|
|
line-height: var(--smLineHeight);
|
|
|
|
}
|
|
|
|
.time {
|
|
|
|
font-size: var(--smFontSize);
|
|
|
|
color: var(--txtHintColor);
|
|
|
|
}
|
|
|
|
</style>
|