Browse Source

chore/gui-v2-date-picker-minor-cleanup

pull/2883/head
Muhammed Mustafa 2 years ago
parent
commit
4923ef7a7b
  1. 7
      packages/nc-gui-v2/components/cell/DatePicker.vue
  2. 3
      packages/nc-gui-v2/utils/dateTimeUtils.ts

7
packages/nc-gui-v2/components/cell/DatePicker.vue

@ -1,14 +1,11 @@
<script setup lang="ts"> <script setup lang="ts">
import dayjs from 'dayjs' import dayjs from 'dayjs'
import customParseFormat from 'dayjs/plugin/customParseFormat'
import { ColumnInj, ReadonlyInj } from '~/context' import { ColumnInj, ReadonlyInj } from '~/context'
const { modelValue } = defineProps<Props>() const { modelValue } = defineProps<Props>()
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
dayjs.extend(customParseFormat)
interface Props { interface Props {
modelValue: string modelValue: string
} }
@ -38,7 +35,7 @@ const localState = $computed({
return return
} }
if (val?.isValid()) { if (val.isValid()) {
emit('update:modelValue', val?.format('YYYY-MM-DD')) emit('update:modelValue', val?.format('YYYY-MM-DD'))
} }
}, },

3
packages/nc-gui-v2/utils/dateTimeUtils.ts

@ -2,8 +2,11 @@ import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime' import relativeTime from 'dayjs/plugin/relativeTime'
import utc from 'dayjs/plugin/utc' import utc from 'dayjs/plugin/utc'
import customParseFormat from 'dayjs/plugin/customParseFormat'
dayjs.extend(utc) dayjs.extend(utc)
dayjs.extend(relativeTime) dayjs.extend(relativeTime)
dayjs.extend(customParseFormat)
export const timeAgo = (date: any) => { export const timeAgo = (date: any) => {
return dayjs.utc(date).fromNow() return dayjs.utc(date).fromNow()

Loading…
Cancel
Save