Skip to content

Commit

Permalink
fix: use locale datetime on full dates
Browse files Browse the repository at this point in the history
  • Loading branch information
rmtsrc committed Dec 31, 2024
1 parent 6443764 commit 2562851
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions web/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ Vue.filter('formatDate', (value) => {
const now = moment();

if (now.isSame(date, 'day')) {
return `${date.fromNow()} (${date.format('HH:mm')})`; // Display only time if today
// Display only time if today
return `${date.fromNow()} (${date.format('HH:mm')})`;
}
return date.format('L HH:mm'); // Display only date otherwise

const dateOptions = { year: 'numeric', month: '2-digit', day: '2-digit' };
const timeOptions = { hour12: false, hour: '2-digit', minute: '2-digit' };
const jsDate = date.toDate();

// Display only date otherwise
return `${jsDate.toLocaleDateString(undefined, dateOptions)} ${jsDate.toLocaleTimeString(undefined, timeOptions)}`;
});
Vue.filter('formatTime', (value) => (value ? moment(String(value)).format('LTS') : '—'));
Vue.filter('formatLog', (value) => (value ? convert.ansi_to_html(String(value)) : value));
Expand Down

0 comments on commit 2562851

Please sign in to comment.