Skip to content

Commit

Permalink
fix seasonal date issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mnsrulz committed Oct 25, 2024
1 parent 801505f commit c12591f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/HistoricalSeason.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ function getDailyData(dt: HistoricalDataResponse) {
if (dt.history.day.length < 2) throw new Error('not enough data...');
const startDate = dayjs(dt.history.day.at(0)?.date, 'YYYY-MM-DD', true);
const endDate = dayjs(dt.history.day.at(-1)?.date, 'YYYY-MM-DD', true);
const firstMonday = dayjs(startDate.subtract(startDate.day() - 1).format('YYYY-MM-DD'), 'YYYY-MM-DD', true);
const firstMonday = startDate.subtract(startDate.day() - 1, 'd');
const numberOfWeeks = endDate.diff(startDate, 'w') + 1;
const ys = [...Array(numberOfWeeks).keys()].reduce((j: string[], c) => {
j.push(`${firstMonday.add(c, 'w').format('DD MMM YY')}`);
return j;
}, []);
let lastClosingPrice = 0;

// console.log(`startDate: ${startDate.format('YYYY-MM-DD')} dayOfWeek: ${startDate.day()} ${startDate.subtract(startDate.day() - 1, 'd')}`);
// console.log(`firstMonday: ${firstMonday.toISOString()} ${firstMonday.format('YYYY-MM-DD')}`);
// console.log(`startDate: ${startDate.toISOString()} ${startDate.format('YYYY-MM-DD')}`);

Expand Down

0 comments on commit c12591f

Please sign in to comment.