fix: sort stock and bond events by payment date

This commit is contained in:
2026-09-30 07:40:43 +03:00
parent 0bc8bc36b7
commit f5f4447d60
5 changed files with 33 additions and 17 deletions
+7 -1
View File
@@ -16,6 +16,12 @@ const moscowFormatter = new Intl.DateTimeFormat("en-CA", {
year: "numeric",
});
// Newest first. Missing dates sort last in both directions, so a row without a
// date never jumps to the top of a "past" list.
function compareDateDesc(a: null | string, b: null | string) {
return (b ?? "").localeCompare(a ?? "");
}
function moscowDate(value: Date): string {
const parts = moscowFormatter.formatToParts(value);
@@ -25,4 +31,4 @@ function moscowDate(value: Date): string {
return `${part("year")}-${part("month")}-${part("day")}`;
}
export { isValidPeriod, moscowDate };
export { compareDateDesc, isValidPeriod, moscowDate };