This commit is contained in:
齐斌 2025-05-28 15:43:06 +08:00
commit de8617321d
4 changed files with 15 additions and 168 deletions

View File

@ -99,7 +99,7 @@
<div class="data-row">
<span style="font-size: 18px" class="data-label"> Time </span>
<span style="font-size: 18px" class="data-value">{{
formattedDate
formatted
}}</span>
</div>
<div class="data-row">
@ -114,8 +114,9 @@
<span style="font-size: 18px" class="data-label">{{
$t("HOME.CONTAINY.STOCK_INFO.CHANGE")
}}</span>
<span style="font-size: 18px" class="data-value positive"
>{{ stockQuote.change[0] }}{{ stockQuote.change[1] }}</span
<span class="data-value positive"
>{{ stockQuote.change?.[0] || "--" }}
{{ stockQuote.change?.[1] || "--" }}</span
>
</div>
<div class="data-row">
@ -199,45 +200,6 @@ const { getStockQuate, stockQuote, formatted } = useStockQuote();
getStockQuate();
const formatCustomDate = (dateString, timeZone = "EDT") => {
//
const date = new Date(dateString);
//
if (isNaN(date.getTime())) {
return "Invalid Date";
}
// AM/PM
const periodMatch = dateString.match(/(AM|PM)/i);
const period = periodMatch ? periodMatch[0] : "AM"; // AM
// Date
let hours = date.getHours();
const minutes = date.getMinutes().toString().padStart(2, "0");
// 12
let displayHours = hours % 12;
displayHours = displayHours || 12; // 0 12
// 2:44AM
const timePart = `${displayHours}:${minutes}${period}`;
// EDT 26/05/25
const day = date.getDate().toString().padStart(2, "0");
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const year = date.getFullYear().toString(); //
const datePart = `${timeZone} ${day}/${month}/${year}`;
//
return `As of ${timePart} ${datePart}`;
};
//
const sampleDate = ref(formatted);
const formattedDate = computed(() => formatCustomDate(sampleDate.value));
const { t: $t } = useI18n();
const contentRef = ref(null);
const isInView = ref(false);

View File

@ -97,7 +97,7 @@
<div class="stock-data">
<div class="data-row">
<span class="data-label"> Time </span>
<span class="data-value">{{ formattedDate }}</span>
<span class="data-value">{{ sampleDate }}</span>
</div>
<div class="data-row">
<span class="data-label">{{
@ -110,7 +110,8 @@
$t("HOME.CONTAINY.STOCK_INFO.CHANGE")
}}</span>
<span class="data-value positive"
>{{ stockQuote.change[0] }}{{ stockQuote.change[1] }}</span
>{{ stockQuote.change?.[0] || "--" }}
{{ stockQuote.change?.[1] || "--" }}</span
>
</div>
<div class="data-row">
@ -185,47 +186,9 @@ import { onMounted, ref, onUnmounted, computed } from "vue";
import { useI18n } from "vue-i18n";
import { useStockQuote } from "@/store/stock-quote/index.js";
const { getStockQuate, stockQuote, formatted } = useStockQuote();
getStockQuate();
const formatCustomDate = (dateString, timeZone = "EDT") => {
//
const date = new Date(dateString);
//
if (isNaN(date.getTime())) {
return "Invalid Date";
}
// AM/PM
const periodMatch = dateString.match(/(AM|PM)/i);
const period = periodMatch ? periodMatch[0] : "AM"; // AM
// Date
let hours = date.getHours();
const minutes = date.getMinutes().toString().padStart(2, "0");
// 12
let displayHours = hours % 12;
displayHours = displayHours || 12; // 0 12
// 2:44AM
const timePart = `${displayHours}:${minutes}${period}`;
// EDT 26/05/25
const day = date.getDate().toString().padStart(2, "0");
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const year = date.getFullYear().toString(); //
const datePart = `${timeZone} ${day}/${month}/${year}`;
//
return `As of ${timePart} ${datePart}`;
};
//
const sampleDate = ref(formatted);
const formattedDate = computed(() => formatCustomDate(sampleDate.value));
const { t: $t } = useI18n();
const contentRef = ref(null);

View File

@ -99,7 +99,7 @@
<div class="data-row">
<span style="font-size: 18px" class="data-label"> Time </span>
<span style="font-size: 18px" class="data-value">{{
formattedDate
formatted
}}</span>
</div>
<div class="data-row">
@ -114,8 +114,9 @@
<span style="font-size: 18px" class="data-label">{{
$t("HOME.CONTAINY.STOCK_INFO.CHANGE")
}}</span>
<span style="font-size: 18px" class="data-value positive"
>{{ stockQuote.change[0] }}{{ stockQuote.change[1] }}</span
<span class="data-value positive"
>{{ stockQuote.change?.[0] || "--" }}
{{ stockQuote.change?.[1] || "--" }}</span
>
</div>
<div class="data-row">
@ -196,48 +197,7 @@ import { onMounted, ref, onUnmounted, computed } from "vue";
import { useI18n } from "vue-i18n";
import { useStockQuote } from "@/store/stock-quote/index.js";
const { getStockQuate, stockQuote, formatted } = useStockQuote();
getStockQuate();
const formatCustomDate = (dateString, timeZone = "EDT") => {
//
const date = new Date(dateString);
//
if (isNaN(date.getTime())) {
return "Invalid Date";
}
// AM/PM
const periodMatch = dateString.match(/(AM|PM)/i);
const period = periodMatch ? periodMatch[0] : "AM"; // AM
// Date
let hours = date.getHours();
const minutes = date.getMinutes().toString().padStart(2, "0");
// 12
let displayHours = hours % 12;
displayHours = displayHours || 12; // 0 12
// 2:44AM
const timePart = `${displayHours}:${minutes}${period}`;
// EDT 26/05/25
const day = date.getDate().toString().padStart(2, "0");
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const year = date.getFullYear().toString(); //
const datePart = `${timeZone} ${day}/${month}/${year}`;
//
return `As of ${timePart} ${datePart}`;
};
//
const sampleDate = ref(formatted);
const formattedDate = computed(() => formatCustomDate(sampleDate.value));
const { t: $t } = useI18n();
const contentRef = ref(null);
const isInView = ref(false);

View File

@ -99,7 +99,7 @@
<div class="data-row">
<span style="font-size: 18px" class="data-label"> Time </span>
<span style="font-size: 18px" class="data-value">{{
formattedDate
formatted
}}</span>
</div>
<div class="data-row">
@ -114,8 +114,9 @@
<span style="font-size: 18px" class="data-label">{{
$t("HOME.CONTAINY.STOCK_INFO.CHANGE")
}}</span>
<span style="font-size: 18px" class="data-value positive"
>{{ stockQuote.change[0] }}{{ stockQuote.change[1] }}</span
<span class="data-value positive"
>{{ stockQuote.change?.[0] || "--" }}
{{ stockQuote.change?.[1] || "--" }}</span
>
</div>
<div class="data-row">
@ -199,45 +200,6 @@ const { getStockQuate, stockQuote, formatted } = useStockQuote();
getStockQuate();
const formatCustomDate = (dateString, timeZone = "EDT") => {
//
const date = new Date(dateString);
//
if (isNaN(date.getTime())) {
return "Invalid Date";
}
// AM/PM
const periodMatch = dateString.match(/(AM|PM)/i);
const period = periodMatch ? periodMatch[0] : "AM"; // AM
// Date
let hours = date.getHours();
const minutes = date.getMinutes().toString().padStart(2, "0");
// 12
let displayHours = hours % 12;
displayHours = displayHours || 12; // 0 12
// 2:44AM
const timePart = `${displayHours}:${minutes}${period}`;
// EDT 26/05/25
const day = date.getDate().toString().padStart(2, "0");
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const year = date.getFullYear().toString(); //
const datePart = `${timeZone} ${day}/${month}/${year}`;
//
return `As of ${timePart} ${datePart}`;
};
//
const sampleDate = ref(formatted);
const formattedDate = computed(() => formatCustomDate(sampleDate.value));
const { t: $t } = useI18n();
const contentRef = ref(null);
const isInView = ref(false);