Browse Source

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

pull/2890/head
Muhammed Mustafa 2 years ago
parent
commit
daf13f6c35
  1. 7
      packages/nc-gui-v2/components/cell/YearPicker.vue
  2. 3
      packages/nc-gui-v2/utils/dateTimeUtils.ts

7
packages/nc-gui-v2/components/cell/YearPicker.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 { ReadonlyInj } from '~/context' import { 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: number modelValue: number
} }
@ -38,7 +35,7 @@ const localState = $computed({
} }
if (val?.isValid()) { if (val?.isValid()) {
emit('update:modelValue', Number(val?.format('YYYY'))) emit('update:modelValue', Number(val.format('YYYY')))
} }
}, },
}) })

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