UNPKG

@opensig/opendesign

Version:

27 lines (26 loc) 650 B
import { computed, toValue } from "vue"; import dayjs from "dayjs"; import { isNil } from "../../_utils/is.mjs"; import { parseValue } from "../utils.mjs"; function useTimestampValue(modelValue, valueFormat) { return computed({ get() { var _a; return (_a = parseValue(modelValue.value)) == null ? void 0 : _a.valueOf(); }, set(ts) { if (isNil(ts)) { modelValue.value = void 0; return; } if (toValue(valueFormat) === "x") { modelValue.value = ts; } else { modelValue.value = dayjs(ts).format(toValue(valueFormat)); } } }); } export { useTimestampValue };