股票时间修改

This commit is contained in:
liwenhao 2025-05-28 15:22:14 +08:00
parent c4b11ec76a
commit f33003eb04
4 changed files with 15 additions and 168 deletions

View File

@ -99,7 +99,7 @@
<div class="data-row"> <div class="data-row">
<span style="font-size: 18px" class="data-label"> Time </span> <span style="font-size: 18px" class="data-label"> Time </span>
<span style="font-size: 18px" class="data-value">{{ <span style="font-size: 18px" class="data-value">{{
formattedDate formatted
}}</span> }}</span>
</div> </div>
<div class="data-row"> <div class="data-row">
@ -114,8 +114,9 @@
<span style="font-size: 18px" class="data-label">{{ <span style="font-size: 18px" class="data-label">{{
$t("HOME.CONTAINY.STOCK_INFO.CHANGE") $t("HOME.CONTAINY.STOCK_INFO.CHANGE")
}}</span> }}</span>
<span style="font-size: 18px" class="data-value positive" <span class="data-value positive"
>{{ stockQuote.change[0] }}{{ stockQuote.change[1] }}</span >{{ stockQuote.change?.[0] || "" }}
{{ stockQuote.change?.[1] || "" }}</span
> >
</div> </div>
<div class="data-row"> <div class="data-row">
@ -199,45 +200,6 @@ const { getStockQuate, stockQuote, formatted } = useStockQuote();
getStockQuate(); 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 { t: $t } = useI18n();
const contentRef = ref(null); const contentRef = ref(null);
const isInView = ref(false); const isInView = ref(false);

View File

@ -97,7 +97,7 @@
<div class="stock-data"> <div class="stock-data">
<div class="data-row"> <div class="data-row">
<span class="data-label"> Time </span> <span class="data-label"> Time </span>
<span class="data-value">{{ formattedDate }}</span> <span class="data-value">{{ sampleDate }}</span>
</div> </div>
<div class="data-row"> <div class="data-row">
<span class="data-label">{{ <span class="data-label">{{
@ -110,7 +110,8 @@
$t("HOME.CONTAINY.STOCK_INFO.CHANGE") $t("HOME.CONTAINY.STOCK_INFO.CHANGE")
}}</span> }}</span>
<span class="data-value positive" <span class="data-value positive"
>{{ stockQuote.change[0] }}{{ stockQuote.change[1] }}</span >{{ stockQuote.change?.[0] || "" }}
{{ stockQuote.change?.[1] || "" }}</span
> >
</div> </div>
<div class="data-row"> <div class="data-row">
@ -185,47 +186,9 @@ import { onMounted, ref, onUnmounted, computed } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useStockQuote } from "@/store/stock-quote/index.js"; import { useStockQuote } from "@/store/stock-quote/index.js";
const { getStockQuate, stockQuote, formatted } = useStockQuote(); const { getStockQuate, stockQuote, formatted } = useStockQuote();
getStockQuate(); 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 sampleDate = ref(formatted);
const formattedDate = computed(() => formatCustomDate(sampleDate.value));
const { t: $t } = useI18n(); const { t: $t } = useI18n();
const contentRef = ref(null); const contentRef = ref(null);

View File

@ -99,7 +99,7 @@
<div class="data-row"> <div class="data-row">
<span style="font-size: 18px" class="data-label"> Time </span> <span style="font-size: 18px" class="data-label"> Time </span>
<span style="font-size: 18px" class="data-value">{{ <span style="font-size: 18px" class="data-value">{{
formattedDate formatted
}}</span> }}</span>
</div> </div>
<div class="data-row"> <div class="data-row">
@ -114,8 +114,9 @@
<span style="font-size: 18px" class="data-label">{{ <span style="font-size: 18px" class="data-label">{{
$t("HOME.CONTAINY.STOCK_INFO.CHANGE") $t("HOME.CONTAINY.STOCK_INFO.CHANGE")
}}</span> }}</span>
<span style="font-size: 18px" class="data-value positive" <span class="data-value positive"
>{{ stockQuote.change[0] }}{{ stockQuote.change[1] }}</span >{{ stockQuote.change?.[0] || "" }}
{{ stockQuote.change?.[1] || "" }}</span
> >
</div> </div>
<div class="data-row"> <div class="data-row">
@ -196,48 +197,7 @@ import { onMounted, ref, onUnmounted, computed } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useStockQuote } from "@/store/stock-quote/index.js"; import { useStockQuote } from "@/store/stock-quote/index.js";
const { getStockQuate, stockQuote, formatted } = useStockQuote(); const { getStockQuate, stockQuote, formatted } = useStockQuote();
getStockQuate(); 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 { t: $t } = useI18n();
const contentRef = ref(null); const contentRef = ref(null);
const isInView = ref(false); const isInView = ref(false);

View File

@ -99,7 +99,7 @@
<div class="data-row"> <div class="data-row">
<span style="font-size: 18px" class="data-label"> Time </span> <span style="font-size: 18px" class="data-label"> Time </span>
<span style="font-size: 18px" class="data-value">{{ <span style="font-size: 18px" class="data-value">{{
formattedDate formatted
}}</span> }}</span>
</div> </div>
<div class="data-row"> <div class="data-row">
@ -114,8 +114,9 @@
<span style="font-size: 18px" class="data-label">{{ <span style="font-size: 18px" class="data-label">{{
$t("HOME.CONTAINY.STOCK_INFO.CHANGE") $t("HOME.CONTAINY.STOCK_INFO.CHANGE")
}}</span> }}</span>
<span style="font-size: 18px" class="data-value positive" <span class="data-value positive"
>{{ stockQuote.change[0] }}{{ stockQuote.change[1] }}</span >{{ stockQuote.change?.[0] || "" }}
{{ stockQuote.change?.[1] || "" }}</span
> >
</div> </div>
<div class="data-row"> <div class="data-row">
@ -199,45 +200,6 @@ const { getStockQuate, stockQuote, formatted } = useStockQuote();
getStockQuate(); 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 { t: $t } = useI18n();
const contentRef = ref(null); const contentRef = ref(null);
const isInView = ref(false); const isInView = ref(false);