Update cardDate.js

This commit is contained in:
valhalla-creator 2025-05-22 21:20:20 +01:00 committed by GitHub
parent 6d4de76a9a
commit fc31eeca88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,13 @@ import moment from 'moment/min/moment-with-locales';
import { TAPi18n } from '/imports/i18n';
import { DatePicker } from '/client/lib/datepicker';
// Add this helper function at the top level
const formatDate = (date, format) => {
if (!date) return '';
const normalizedDate = Utils.normalizeDigits(moment(date).format(format));
return normalizedDate;
};
// editCardReceivedDatePopup
(class extends DatePicker {
onCreated() {
@ -166,6 +173,10 @@ class CardReceivedDate extends CardDate {
'click .js-edit-date': Popup.open('editCardReceivedDate'),
});
}
showDate() {
return formatDate(this.date.get(), 'L');
}
}
CardReceivedDate.register('cardReceivedDate');
@ -201,6 +212,10 @@ class CardStartDate extends CardDate {
'click .js-edit-date': Popup.open('editCardStartDate'),
});
}
showDate() {
return formatDate(this.date.get(), 'L');
}
}
CardStartDate.register('cardStartDate');
@ -237,6 +252,10 @@ class CardDueDate extends CardDate {
'click .js-edit-date': Popup.open('editCardDueDate'),
});
}
showDate() {
return formatDate(this.date.get(), 'L');
}
}
CardDueDate.register('cardDueDate');
@ -268,6 +287,10 @@ class CardEndDate extends CardDate {
'click .js-edit-date': Popup.open('editCardEndDate'),
});
}
showDate() {
return formatDate(this.date.get(), 'L');
}
}
CardEndDate.register('cardEndDate');
@ -317,31 +340,31 @@ CardCustomFieldDate.register('cardCustomFieldDate');
(class extends CardReceivedDate {
showDate() {
return this.date.get().format('L');
return formatDate(this.date.get(), 'L');
}
}.register('minicardReceivedDate'));
(class extends CardStartDate {
showDate() {
return this.date.get().format('YYYY-MM-DD HH:mm');
return formatDate(this.date.get(), 'YYYY-MM-DD HH:mm');
}
}.register('minicardStartDate'));
(class extends CardDueDate {
showDate() {
return this.date.get().format('YYYY-MM-DD HH:mm');
return formatDate(this.date.get(), 'YYYY-MM-DD HH:mm');
}
}.register('minicardDueDate'));
(class extends CardEndDate {
showDate() {
return this.date.get().format('YYYY-MM-DD HH:mm');
return formatDate(this.date.get(), 'YYYY-MM-DD HH:mm');
}
}.register('minicardEndDate'));
(class extends CardCustomFieldDate {
showDate() {
return this.date.get().format('L');
return formatDate(this.date.get(), 'L');
}
}.register('minicardCustomFieldDate'));
@ -358,7 +381,7 @@ class VoteEndDate extends CardDate {
return classes;
}
showDate() {
return this.date.get().format('L LT');
return formatDate(this.date.get(), 'L LT');
}
showTitle() {
return `${TAPi18n.__('card-end-on')} ${this.date.get().format('LLLL')}`;
@ -385,7 +408,7 @@ class PokerEndDate extends CardDate {
return classes;
}
showDate() {
return this.date.get().format('l LT');
return formatDate(this.date.get(), 'L LT');
}
showTitle() {
return `${TAPi18n.__('card-end-on')} ${this.date.get().format('LLLL')}`;