@burh/nuxt-core 1.1.26 → 1.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -292,7 +292,8 @@ export default {
|
|
|
292
292
|
return this.$store.state.company.currentCompany;
|
|
293
293
|
},
|
|
294
294
|
userHasBirthDate() {
|
|
295
|
-
|
|
295
|
+
const birth = this.userData && this.userData.user_complementary_information && this.userData.user_complementary_information.birth;
|
|
296
|
+
return !!this.parseBirthDate(birth);
|
|
296
297
|
}
|
|
297
298
|
},
|
|
298
299
|
props: {
|
|
@@ -321,9 +322,48 @@ export default {
|
|
|
321
322
|
handleAboutmeDownloadClick() {
|
|
322
323
|
this.$emit('aboutme-download');
|
|
323
324
|
},
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
parseBirthDate(birth) {
|
|
326
|
+
if (!birth) return null;
|
|
327
|
+
|
|
328
|
+
if (birth instanceof Date) {
|
|
329
|
+
return isNaN(birth.getTime()) ? null : birth;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (typeof birth === 'number') {
|
|
333
|
+
const d = new Date(birth);
|
|
334
|
+
return isNaN(d.getTime()) ? null : d;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (typeof birth === 'string') {
|
|
338
|
+
const trimmed = birth.trim();
|
|
339
|
+
const match = trimmed.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
340
|
+
if (match) {
|
|
341
|
+
const year = Number(match[1]);
|
|
342
|
+
const monthIndex = Number(match[2]) - 1;
|
|
343
|
+
const day = Number(match[3]);
|
|
344
|
+
const d = new Date(year, monthIndex, day);
|
|
345
|
+
return isNaN(d.getTime()) ? null : d;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const d = new Date(trimmed);
|
|
349
|
+
return isNaN(d.getTime()) ? null : d;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return null;
|
|
353
|
+
},
|
|
354
|
+
getAge() {
|
|
355
|
+
const birth = this.userData && this.userData.user_complementary_information && this.userData.user_complementary_information.birth;
|
|
356
|
+
const birthDate = this.parseBirthDate(birth);
|
|
357
|
+
if (!birthDate) return '';
|
|
358
|
+
|
|
359
|
+
const today = new Date();
|
|
360
|
+
let years = today.getFullYear() - birthDate.getFullYear();
|
|
361
|
+
const monthDiff = today.getMonth() - birthDate.getMonth();
|
|
362
|
+
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
|
|
363
|
+
years -= 1;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return years >= 0 ? years : 0;
|
|
327
367
|
},
|
|
328
368
|
highlightText(search, text) {
|
|
329
369
|
if (search.length < 2) return text;
|