Add 12 hours expiration preset (#7738)

* Add hours precision to TimeDelta

* Add 12 hours expiration preset

Fixes #7369
This commit is contained in:
Bernhard Kirchen 2022-03-31 13:02:28 +02:00 committed by GitHub
parent 044fc8d50c
commit aca197a96f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 13 deletions

View file

@ -21,38 +21,53 @@
QDateTime operator+(const QDateTime& dateTime, const TimeDelta& delta)
{
return dateTime.addDays(delta.getDays()).addMonths(delta.getMonths()).addYears(delta.getYears());
return dateTime.addSecs(delta.getHours() * 3600)
.addDays(delta.getDays())
.addMonths(delta.getMonths())
.addYears(delta.getYears());
}
TimeDelta TimeDelta::fromHours(int hours)
{
return TimeDelta(hours, 0, 0, 0);
}
TimeDelta TimeDelta::fromDays(int days)
{
return TimeDelta(days, 0, 0);
return TimeDelta(0, days, 0, 0);
}
TimeDelta TimeDelta::fromMonths(int months)
{
return TimeDelta(0, months, 0);
return TimeDelta(0, 0, months, 0);
}
TimeDelta TimeDelta::fromYears(int years)
{
return TimeDelta(0, 0, years);
return TimeDelta(0, 0, 0, years);
}
TimeDelta::TimeDelta()
: m_days(0)
: m_hours(0)
, m_days(0)
, m_months(0)
, m_years(0)
{
}
TimeDelta::TimeDelta(int days, int months, int years)
: m_days(days)
TimeDelta::TimeDelta(int hours, int days, int months, int years)
: m_hours(hours)
, m_days(days)
, m_months(months)
, m_years(years)
{
}
int TimeDelta::getHours() const
{
return m_hours;
}
int TimeDelta::getDays() const
{
return m_days;