diff --git a/methods/sqv.cc b/methods/sqv.cc index ac73673..7ce3ab1 100644 --- a/methods/sqv.cc +++ b/methods/sqv.cc @@ -3,6 +3,7 @@ #include "aptmethod.h" #include #include +#include #include #include #include @@ -228,8 +229,13 @@ bool SQVMethod::VerifyGetSigners(const char *file, const char *outfile, _error->PushToStack(); auto time = std::time(nullptr); auto tm = std::localtime(&time); + using namespace std::chrono; + auto yearAhead = year_month_day{year{tm->tm_year + 1900}, month(tm->tm_mon + 1), day(tm->tm_mday)} + years{1}; + // 29 February has no counterpart in the next year + if (not yearAhead.ok()) + yearAhead = year_month_day_last{yearAhead.year(), month_day_last{yearAhead.month()}}; std::string yearAheadDate; - strprintf(yearAheadDate, "%d-%d-%d", tm->tm_year + 1900 + 1, tm->tm_mon + 1, tm->tm_mday); + strprintf(yearAheadDate, "%d-%u-%u", int(yearAhead.year()), unsigned(yearAhead.month()), unsigned(yearAhead.day())); args.push_back("--policy-as-of"); args.push_back(std::move(yearAheadDate));