bugfixing group earnings
This commit is contained in:
parent
ec27fd44d9
commit
7014bfdb41
@ -159,35 +159,32 @@ export const groupScreenerRules = (allRows) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const groupEarnings = (earnings) => {
|
export const groupEarnings = (earnings) => {
|
||||||
return Object?.entries(
|
return Object?.entries(
|
||||||
earnings?.reduce((acc, item) => {
|
earnings?.reduce((acc, item) => {
|
||||||
const date = new Date(item?.date);
|
// Force formatting in UTC to avoid local timezone conversion
|
||||||
const berlinDate = new Intl.DateTimeFormat('en-US', {
|
const dateKey = new Intl.DateTimeFormat('en-US', {
|
||||||
day: '2-digit',
|
day: '2-digit',
|
||||||
month: 'short',
|
month: 'short',
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
timeZone: 'Europe/Berlin'
|
timeZone: 'UTC'
|
||||||
}).format(date);
|
})?.format(new Date(item.date));
|
||||||
|
|
||||||
if (!acc[berlinDate]) acc[berlinDate] = [];
|
if (!acc[dateKey]) acc[dateKey] = [];
|
||||||
acc[berlinDate]?.push(item);
|
acc[dateKey].push(item);
|
||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {})
|
||||||
)
|
)
|
||||||
// Sort the grouped dates in descending order (most recent first)
|
// Sort the grouped dates in descending order
|
||||||
?.sort(([dateA], [dateB]) => new Date(dateB) - new Date(dateA))
|
?.sort(([dateA], [dateB]) => new Date(dateA) - new Date(dateB))
|
||||||
?.map(([date, earnings]) => [
|
?.map(([date, earnings]) => [
|
||||||
date,
|
date,
|
||||||
// Sort earnings within the date by time in descending order
|
// Sort earnings within the date by time (also treat times as UTC)
|
||||||
earnings?.sort((a, b) => {
|
earnings?.sort((a, b) => {
|
||||||
const berlinTimeA = new Date(
|
const timeA = new Date(`1970-01-01T${a?.time}Z`);
|
||||||
new Date(`${a?.date}T${a?.time}`).toLocaleString('en-US', { timeZone: 'Europe/Berlin' })
|
const timeB = new Date(`1970-01-01T${b?.time}Z`);
|
||||||
);
|
return timeB - timeA;
|
||||||
const berlinTimeB = new Date(
|
|
||||||
new Date(`${b?.date}T${b?.time}`).toLocaleString('en-US', { timeZone: 'Europe/Berlin' })
|
|
||||||
);
|
|
||||||
return berlinTimeB - berlinTimeA;
|
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -277,8 +277,8 @@
|
|||||||
if (watchList?.length > 0) {
|
if (watchList?.length > 0) {
|
||||||
columns = generateColumns(watchList);
|
columns = generateColumns(watchList);
|
||||||
sortOrders = generateSortOrders(watchList);
|
sortOrders = generateSortOrders(watchList);
|
||||||
|
|
||||||
groupedEarnings = groupEarnings(earnings);
|
groupedEarnings = groupEarnings(earnings);
|
||||||
|
|
||||||
groupedNews = groupNews(news, watchList);
|
groupedNews = groupNews(news, watchList);
|
||||||
} else {
|
} else {
|
||||||
groupedEarnings = [];
|
groupedEarnings = [];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user