title: JavaScript: is there a way to detect that a given date in such a format is within last X days?
body: <p>I have a bunch of timestamp formatted like this</p>
  <pre class="lang-js prettyprint-override"><code>const dates = ['2021.6.01', '2021.6.11', '2021.9.02']
  </code></pre>
  <p>I wanted to write a util that can tell me if a date with such a format is within the last X days of another date.</p>
  <p>For example, <code>2021.6.10</code> is within the last 7 days of <code>2021.6.12</code> while <code>2021.6.01</code> is not within the last 7 days of <code>2021.6.12</code>.</p>
  <p>I was think the API interface would be but please feel free to suggest a better naming</p>
  <pre class="lang-js prettyprint-override"><code>function isWithinTheLastDays(originalDate, date, days)
  </code></pre>
  <p>I found it really tricky to implement by hand and there are a lot of edge cases.</p>