support calendar display type (Gregorian and Buddhist)
This commit is contained in:
@@ -2,12 +2,7 @@ import { ref, computed } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
import { useUserStore } from '@/stores/user.ts';
|
||||
|
||||
import { type NameValue } from '@/core/base.ts';
|
||||
import { type WeekDayValue } from '@/core/datetime.ts';
|
||||
import { arrangeArrayWithNewStartIndex } from '@/lib/common.ts';
|
||||
import { getAllowedYearRange } from '@/lib/datetime.ts';
|
||||
|
||||
export interface TimePickerValue {
|
||||
value: string;
|
||||
@@ -16,9 +11,7 @@ export interface TimePickerValue {
|
||||
|
||||
export function useDateTimeSelectionBase() {
|
||||
const {
|
||||
getAllMinWeekdayNames,
|
||||
getAllMeridiemIndicators,
|
||||
isLongDateMonthAfterYear,
|
||||
isLongTime24HourFormat,
|
||||
isLongTimeMeridiemIndicatorFirst,
|
||||
isLongTimeHourTwoDigits,
|
||||
@@ -26,22 +19,14 @@ export function useDateTimeSelectionBase() {
|
||||
isLongTimeSecondTwoDigits
|
||||
} = useI18n();
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
const is24Hour = ref<boolean>(isLongTime24HourFormat());
|
||||
const isHourTwoDigits = ref<boolean>(isLongTimeHourTwoDigits());
|
||||
const isMinuteTwoDigits = ref<boolean>(isLongTimeMinuteTwoDigits());
|
||||
const isSecondTwoDigits = ref<boolean>(isLongTimeSecondTwoDigits());
|
||||
const isMeridiemIndicatorFirst = ref<boolean>(isLongTimeMeridiemIndicatorFirst() || false);
|
||||
|
||||
const yearRange = ref<number[]>(getAllowedYearRange());
|
||||
|
||||
const meridiemItems = computed<NameValue[]>(() => getAllMeridiemIndicators());
|
||||
|
||||
const firstDayOfWeek = computed<WeekDayValue>(() => userStore.currentUserFirstDayOfWeek);
|
||||
const dayNames = computed<string[]>(() => arrangeArrayWithNewStartIndex(getAllMinWeekdayNames(), firstDayOfWeek.value));
|
||||
const isYearFirst = computed<boolean>(() => isLongDateMonthAfterYear());
|
||||
|
||||
function getDisplayTimeValue(value: number, forceTwoDigits: boolean): string {
|
||||
if (forceTwoDigits && value < 10) {
|
||||
return `0${value}`;
|
||||
@@ -96,12 +81,8 @@ export function useDateTimeSelectionBase() {
|
||||
isMinuteTwoDigits,
|
||||
isSecondTwoDigits,
|
||||
isMeridiemIndicatorFirst,
|
||||
yearRange,
|
||||
// computed
|
||||
meridiemItems,
|
||||
firstDayOfWeek,
|
||||
dayNames,
|
||||
isYearFirst,
|
||||
// functions
|
||||
getDisplayTimeValue,
|
||||
generateAllHours,
|
||||
|
||||
Reference in New Issue
Block a user