modified: serv_nginx/bbvue/src/views/Profile.vue

Fix bag with the not correct date on Profile page. Begushiybashkir.ru
site
This commit is contained in:
2025-10-20 01:00:29 +05:00
parent 9e2051cbfe
commit d1d6b24765
+30 -12
View File
@@ -247,30 +247,48 @@ export default {
return baseUrl + filename; return baseUrl + filename;
}, },
joinDate() { joinDate() {
// Добавим отладку для всего объекта user if (!this.user?.created_at) {
console.log('DEBUG - user object:', this.user);
console.log('DEBUG - user keys:', this.user ? Object.keys(this.user) : 'no user');
if (!this.user?.createdAt) {
console.log('DEBUG - createdAt is missing or falsy');
return 'Неизвестно'; return 'Неизвестно';
} }
if (!this.user?.createdAt) return 'Неизвестно';
console.log('DEBUG - createdAt:', this.user.createdAt, 'Type:', typeof this.user.createdAt); console.log('DEBUG - created_at:', this.user.created_at, 'Type:', typeof this.user.created_at);
// Пробуем разные форматы даты
let date;
if (this.user.created_at.includes('T')) {
// ISO формат
date = new Date(this.user.created_at);
} else {
// Другие форматы
date = new Date(this.user.created_at.replace(' ', 'T'));
}
// Пробуем просто создать дату
const date = new Date(this.user.createdAt);
console.log('DEBUG - parsed date:', date); console.log('DEBUG - parsed date:', date);
if (isNaN(date.getTime())) { if (isNaN(date.getTime())) {
return 'Неизвестно'; // Если все еще ошибка, пробуем убрать микросекунды
const cleanDate = this.user.created_at.split('.')[0];
date = new Date(cleanDate);
if (isNaN(date.getTime())) {
return 'Неизвестно';
}
} }
const month = date.toLocaleString('ru-RU', { month: 'long' }); const month = date.toLocaleString('ru-RU', { month: 'long' });
const year = date.getFullYear(); const year = date.getFullYear();
return `${month} ${year}`; // Склоняем месяц
const monthNames = {
'январь': 'января', 'февраль': 'февраля', 'март': 'марта',
'апрель': 'апреля', 'май': 'мая', 'июнь': 'июня',
'июль': 'июля', 'август': 'августа', 'сентябрь': 'сентября',
'октябрь': 'октября', 'ноябрь': 'ноября', 'декабрь': 'декабря'
};
const monthName = monthNames[month] || month;
return `${monthName} ${year}`;
}, },
experienceLabel() { experienceLabel() {
const experienceMap = { const experienceMap = {