title: Get fiscal year based on current timestamp-python
body: <blockquote>
    <blockquote>
      <p>I am trying get the start date of the financial year based on today's date.</p>
    </blockquote>
  </blockquote>
  
  <p>So after a little research, I found this package called <a href="https://fiscalyear.readthedocs.io/en/latest/installation.html" rel="nofollow noreferrer"><code>fiscalyear</code></a> where you can modify the start date of the fiscal year. In my case i wanted <strong><code>01-07-year</code></strong> to be the start date of my fiscal year so i set <code>fiscalyear.START_MONTH = 7</code></p>
  
  <p>I have tried the below(reproducible example if you <code>pip install fiscalyear</code>):</p>
  
  <pre><code>import datetime
  import fiscalyear
  fiscalyear.START_MONTH = 7
  a = fiscalyear.FiscalYear(datetime.datetime.now().year).start.date()
  a.strftime('%Y-%m-%d')
  </code></pre>
  
  <p>Which outputs correctly:</p>
  
  <pre><code>'2018-07-01'
  </code></pre>
  
  <p>However, this would not work when the month turns to August, since the <code>datetime.datetime.now().year</code> doesnot change. So i tried doing something like:</p>
  
  <pre><code>if (datetime.datetime.now()-pd.to_datetime('2018-07-01')).days &lt; 365:
      a = fiscalyear.FiscalYear(datetime.datetime.now().year).start.date()
      print(a.strftime('%Y-%m-%d'))
  else:
      a = fiscalyear.FiscalYear(datetime.datetime.now().year+1).start.date()
      print(a.strftime('%Y-%m-%d'))
  </code></pre>
  
  <p>I have a bad feeling about what I am doing since this might now work for leap years too.</p>
  
  <blockquote>
    <blockquote>
      <p>Is there some better way to do this in python which will detect the start date of the fiscal year based on current timestamp?</p>
    </blockquote>
  </blockquote>
  
  <p><em>py version</em>: <code>3.6.7</code></p>