fix(dates): enforce standard Iranian calendar dates for default values and monthly range
This commit is contained in:
@@ -35,7 +35,7 @@ export function usePersianDate() {
|
||||
const toJalaliPickerValue = (value) => {
|
||||
if (!value) return '';
|
||||
try {
|
||||
return moment(value).locale('fa').format('jYYYY/jMM/jDD');
|
||||
return toLatinDigits(moment(value).locale('fa').format('jYYYY/jMM/jDD'));
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
@@ -56,7 +56,11 @@ export function usePersianDate() {
|
||||
const jalaliToIso = (jalaliStr) => toGregorianIso(jalaliStr) || null;
|
||||
|
||||
const getTodayJalali = (formatStr = 'jYYYY/jMM/jDD') => {
|
||||
return moment().locale('fa').format(formatStr);
|
||||
return toLatinDigits(moment().locale('fa').format(formatStr));
|
||||
};
|
||||
|
||||
const getStartOfJalaliMonth = (formatStr = 'jYYYY/jMM/jDD') => {
|
||||
return toLatinDigits(moment().startOf('jMonth').locale('fa').format(formatStr));
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -67,7 +71,9 @@ export function usePersianDate() {
|
||||
toJalaliPickerValue,
|
||||
toGregorianIso,
|
||||
jalaliToIso,
|
||||
getTodayJalali
|
||||
getTodayJalali,
|
||||
getStartOfJalaliMonth
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -159,10 +159,11 @@ const resetForm = () => {
|
||||
form.title = '';
|
||||
form.category = '';
|
||||
form.amount = 0;
|
||||
form.date = toJalaliPickerValue(new Date());
|
||||
form.date = getTodayJalali();
|
||||
form.notes = '';
|
||||
};
|
||||
|
||||
|
||||
const openCreateModal = () => {
|
||||
isEditMode.value = false;
|
||||
editingId.value = null;
|
||||
|
||||
@@ -340,7 +340,7 @@ import TabPanel from 'primevue/tabpanel';
|
||||
import DatePicker from 'vue3-persian-datetime-picker';
|
||||
|
||||
const route = useRoute();
|
||||
const { toPersianDigits, formatJalali, toGregorianIso, toJalaliPickerValue, getTodayJalali } = usePersianDate();
|
||||
const { toPersianDigits, formatJalali, toGregorianIso, toJalaliPickerValue, getTodayJalali, getStartOfJalaliMonth } = usePersianDate();
|
||||
const { showError } = useToast();
|
||||
|
||||
const formatToman = (value) => `${toPersianDigits(Math.round(value || 0).toLocaleString())} تومان`;
|
||||
@@ -416,12 +416,11 @@ const rangeReport = ref(null);
|
||||
const isRangeReportLoading = ref(false);
|
||||
|
||||
const setThisMonth = () => {
|
||||
const now = new Date();
|
||||
const first = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||
rangeForm.startDate = toJalaliPickerValue(first);
|
||||
rangeForm.endDate = toJalaliPickerValue(now);
|
||||
rangeForm.startDate = getStartOfJalaliMonth();
|
||||
rangeForm.endDate = getTodayJalali();
|
||||
};
|
||||
|
||||
|
||||
const loadRangeReport = async () => {
|
||||
isRangeReportLoading.value = true;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user