Enhance date formatting in NobilityView: Update formatDate method to display time for today's or future dates, improving user experience by providing more relevant information.
This commit is contained in:
@@ -138,6 +138,21 @@
|
||||
},
|
||||
formatDate(isoString) {
|
||||
const d = new Date(isoString);
|
||||
const now = new Date();
|
||||
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
const dateOnly = new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
||||
|
||||
// Wenn das Datum heute ist oder in der Zukunft liegt, zeige auch die Uhrzeit
|
||||
if (dateOnly.getTime() >= today.getTime()) {
|
||||
return d.toLocaleString(navigator.language, {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
}
|
||||
// Ansonsten nur das Datum
|
||||
return d.toLocaleDateString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user