title: How to check if input Date is valid
body: <p>I would like to know how to check if the date that I inputted is valid.</p>
  <pre><code>public static bool JeVeljavenDatum(int dan, int mesec, int leto)
      {
          return dan &gt; 0 &amp;&amp; dan &lt;= 31 &amp;&amp; mesec &gt; 0 &amp;&amp; mesec &lt;= 12 &amp;&amp; leto &gt; 0 &amp;&amp; leto &lt;= DateTime.Today.Year;
  
      }    
  </code></pre>
  <p>As shown above I don't really think that function is the optimal way to check the date so any tips would be welcome :)</p>
  <p>The problem is checking if the year is leap or not and when the months are only 30 days or 31.
  Or is the only way to check that with the long if methods like this.</p>
  <pre><code>if ((Mesec == 1 || Mesec == 3 || Mesec == 5 || Mesec == 7 || Mesec == 8 || Mesec == 10 || Mesec == 12) &amp;&amp; Dan == 31)
          {
              Dan = 1;
              Mesec++;
  
              if (Mesec == 12)
              {
                  Mesec = 1;
                  Leto++;
              }
  
          }
  
          if ((Mesec == 4 || Mesec == 6 || Mesec == 9 || Mesec == 11) &amp;&amp; Dan == 30)
          {
              Dan = 1;
              Mesec++;
  
              if (Mesec == 12)
              {
                  Mesec = 1;
                  Leto++;
              }
  
          }
  </code></pre>