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 22, 2024
2 parents 1a75d6d + daa4717 commit 19b668d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions myems-web/src/components/MyEMS/Microgrid/MicrogridReporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,38 @@ const MicrogridReportingEnergy = ({ setRedirect, setRedirectUrl, t }) => {
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 19b668d

Please sign in to comment.