Fix date time timezone
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
98cf665126
commit
c34fc0f79e
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { toDate } from 'src/filters';
|
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
|
import isValidDate from "filters/isValidDate";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
@ -54,6 +54,16 @@ const formatDate = (dateString) => {
|
||||||
date.getDate()
|
date.getDate()
|
||||||
)}`;
|
)}`;
|
||||||
};
|
};
|
||||||
|
const displayDate = (dateString) => {
|
||||||
|
if (!dateString || !isValidDate(dateString)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return new Date(dateString).toLocaleDateString([], {
|
||||||
|
year: 'numeric',
|
||||||
|
month: '2-digit',
|
||||||
|
day: '2-digit',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const styleAttrs = computed(() => {
|
const styleAttrs = computed(() => {
|
||||||
return props.isOutlined
|
return props.isOutlined
|
||||||
|
@ -69,7 +79,7 @@ const styleAttrs = computed(() => {
|
||||||
<template>
|
<template>
|
||||||
<VnInput
|
<VnInput
|
||||||
class="vn-input-date"
|
class="vn-input-date"
|
||||||
:model-value="toDate(value)"
|
:model-value="displayDate(value)"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||||
readonly
|
readonly
|
||||||
@click="isPopupOpen = true"
|
@click="isPopupOpen = true"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { toHour } from 'src/filters';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import isValidDate from 'filters/isValidDate';
|
import isValidDate from 'filters/isValidDate';
|
||||||
import VnInput from "components/common/VnInput.vue";
|
import VnInput from "components/common/VnInput.vue";
|
||||||
|
@ -41,14 +40,13 @@ const value = computed({
|
||||||
const isPopupOpen = ref(false);
|
const isPopupOpen = ref(false);
|
||||||
const onDateUpdate = (date) => {
|
const onDateUpdate = (date) => {
|
||||||
internalValue.value = date;
|
internalValue.value = date;
|
||||||
isPopupOpen.value = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = () => {
|
const save = () => {
|
||||||
value.value = internalValue.value;
|
value.value = internalValue.value;
|
||||||
};
|
};
|
||||||
const formatTime = (dateString) => {
|
const formatTime = (dateString) => {
|
||||||
if (!isValidDate(dateString)) {
|
if (!dateString || !isValidDate(dateString)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +74,7 @@ const styleAttrs = computed(() => {
|
||||||
<VnInput
|
<VnInput
|
||||||
class="vn-input-time"
|
class="vn-input-time"
|
||||||
readonly
|
readonly
|
||||||
:model-value="toHour(value)"
|
:model-value="formatTime(value)"
|
||||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||||
@click="isPopupOpen = true"
|
@click="isPopupOpen = true"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue