fix: sort stock and bond events by payment date
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user