Fix: for time change summer -> winter term. Compute minutes until midnight manually.
This commit is contained in:
		@@ -65,13 +65,22 @@ struct ATBTariffCarryOver {
 | 
				
			|||||||
        int minutes = 0;
 | 
					        int minutes = 0;
 | 
				
			||||||
        QString end = m_range.m_end.toString(Qt::ISODate);
 | 
					        QString end = m_range.m_end.toString(Qt::ISODate);
 | 
				
			||||||
        if (end == "24:00:00") {
 | 
					        if (end == "24:00:00") {
 | 
				
			||||||
            QDateTime t = dt.addDays(1);
 | 
					            // note: this did not work
 | 
				
			||||||
            t.setTime(QTime(0,0,0));
 | 
					            // QDateTime t(dt.addDays(1));
 | 
				
			||||||
            minutes = dt.secsTo(t) / 60;
 | 
					            // t.setTime(QTime(0,0,0));
 | 
				
			||||||
 | 
					            // dt: 2024-10-27T00:00:00 EEST, but t: 2024-10-28T00:00:00 EET (!)
 | 
				
			||||||
 | 
					            // so the difference is 1500 instead of 1440
 | 
				
			||||||
 | 
					            // reason: change from summer to winter time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // compute minutes directly
 | 
				
			||||||
 | 
					            if (dt.time().isValid()) {
 | 
				
			||||||
 | 
					                minutes = 1440 - (dt.time().hour() * 60 + dt.time().minute());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            QDateTime t(dt);
 | 
					            QTime t(QTime::fromString(end, Qt::ISODate));
 | 
				
			||||||
            t.setTime(QTime::fromString(end, Qt::ISODate));
 | 
					            if (t.isValid() && dt.time().isValid()) {
 | 
				
			||||||
            minutes = dt.secsTo(t) / 60;
 | 
					                minutes = (t.hour() * 60 + t.minute()) - (dt.time().hour() * 60 + dt.time().minute());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (minutes < 0 || minutes > m_range.m_duration) {
 | 
					        if (minutes < 0 || minutes > m_range.m_duration) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user