title: C++ Subtracting days from current time using date.h
body: <p>I am trying to subtract a number of days from the current time using the <code>date.h</code> library of Howard Hinnant.</p>
  <pre><code>auto currentTime()
  {
      using namespace std::chrono;
      return date::floor&lt;seconds&gt;(system_clock::now());
  }
  
  auto oldDate(date::days daysNum)
  {
      using namespace date;
      auto time = currentTime();
      auto sd = floor&lt;days&gt;(time);
      auto time_of_day = time - sd;
      auto ymd = year_month_day{sd} - daysNum;
      if (!ymd.ok())
          ymd = ymd.year()/ymd.month()/last;
      return sys_days{ymd} + time_of_day;
  }
  
  int main(){
      oldDate(date::days{10});
      return 0;
  }
  </code></pre>
  <p>However, the compiler complains about <code>auto ymd = year_month_day{sd} - daysNum;</code>. The error is:</p>
  <pre><code>no match for `operator-` (operand types are `date::year_month_day` and `date::days {aka std::chrono::duration&lt;int, std::ratio&lt;86400l, 1l&gt; &gt;}`)
  </code></pre>
  <p>Could someone kindly help?</p>