Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nengyuanzhang committed Jul 23, 2024
2 parents 53eafe2 + bea1e3c commit 050565c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,38 @@ const EnergyStoragePowerStationReportingEnergy = ({ setRedirect, setRedirectUrl,
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
const dateDifferenceInSeconds = moment(DateRange[1]).valueOf() / 1000 - moment(DateRange[0]).valueOf() / 1000;
if (periodType === 'hourly') {
if (dateDifferenceInSeconds > 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds > 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
} else if (dateDifferenceInSeconds > 30 * 24 * 60 * 60) {
// more than 30 days
setPeriodType('daily');
document.getElementById('periodType').value = 'daily';
}
} else if (periodType === 'daily') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds >= 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
}
} else if (periodType === 'monthly') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
}
}
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([
moment(DateRange[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,38 @@ const EnergyStoragePowerStationReportingRevenue = ({ setRedirect, setRedirectUrl
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
const dateDifferenceInSeconds = moment(DateRange[1]).valueOf() / 1000 - moment(DateRange[0]).valueOf() / 1000;
if (periodType === 'hourly') {
if (dateDifferenceInSeconds > 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds > 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
} else if (dateDifferenceInSeconds > 30 * 24 * 60 * 60) {
// more than 30 days
setPeriodType('daily');
document.getElementById('periodType').value = 'daily';
}
} else if (periodType === 'daily') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
} else if (dateDifferenceInSeconds >= 6 * 30 * 24 * 60 * 60) {
// more than 6 months
setPeriodType('monthly');
document.getElementById('periodType').value = 'monthly';
}
} else if (periodType === 'monthly') {
if (dateDifferenceInSeconds >= 3 * 365 * 24 * 60 * 60) {
// more than 3 years
setPeriodType('yearly');
document.getElementById('periodType').value = 'yearly';
}
}
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([
moment(DateRange[0])
Expand Down

0 comments on commit 050565c

Please sign in to comment.