title: Check if given string is valid format string for converting DateTime
body: <p><strong>TLDR;</strong></p>
  
  <p>I need to validate whether a given input string is a valid "<em>format string</em>" for parsing DateTime. For example,</p>
  
  <ul>
  <li><code>yy-mm-dd</code> is valid</li>
  <li><code>yy-aaaaaaa123</code> is not valid</li>
  </ul>
  
  <hr>
  
  <p>I am working on a <a href="https://github.com/kolappannathan/simple-csv-logger/blob/master/src/nk.logger.csv/Logger.cs" rel="nofollow noreferrer">program</a> which accepts Date format as an input from the user. Below is my stripped out the code</p>
  
  <pre class="lang-csharp prettyprint-override"><code>private string datetimeFormat;
  
  public Logger(string dateFormat)
  {
      datetimeFormat = dateFormat;
  }
  
  ...
  ...
  ...
  
  // Inside some function
  string pretext = $"{DateTime.Now.ToString(datetimeFormat)},{logLevel},";
  </code></pre>
  
  <p>I need to add validation for the <code>dateFormat</code> string input.</p>
  
  <p>I am thinking of having many possible combinations in an array and accept only those strings. But is there any other way to validate?</p>
  
  <hr>
  
  <p><strong>Updates</strong>:</p>
  
  <p>My input string does not contain any date. This is not a duplicate of the <a href="https://stackoverflow.com/q/19019718/5407188">specified question</a>.</p>
  
  <p><a href="https://stackoverflow.com/q/7974597/5407188">This question</a> is not about DateTime at all.</p>