Fixed date parsing in database queries.
This commit is contained in:
@@ -95,17 +95,22 @@ export function getDateArray(data, startDate, endDate, unit) {
|
||||
const arr = [];
|
||||
const [diff, add, normalize] = dateFuncs[unit];
|
||||
const n = diff(endDate, startDate) + 1;
|
||||
console.log({ startDate, endDate, n });
|
||||
|
||||
function findData(t) {
|
||||
const x = data.find(e => {
|
||||
return getLocalTime(new Date(e.t)).getTime() === normalize(new Date(t)).getTime();
|
||||
if (unit === 'day') {
|
||||
const [year, month, day] = e.t.split('-');
|
||||
return normalize(new Date(year, month - 1, day)).getTime() === t.getTime();
|
||||
}
|
||||
return normalize(new Date(e.t)).getTime() === t.getTime();
|
||||
});
|
||||
|
||||
return x?.y || 0;
|
||||
}
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
const t = add(startDate, i);
|
||||
const t = normalize(add(startDate, i));
|
||||
const y = findData(t);
|
||||
|
||||
arr.push({ ...data[i], t, y });
|
||||
|
||||
Reference in New Issue
Block a user